Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-haiku-20241022· AnthropicHugging Face LMArena Human Preference 140K

now add 5 damage if touching a player but have a cooldown, and also add chance to do…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen-max-2025-01-25’s answer.
  1. User

    now add 5 damage if touching a player but have a cooldown, and also add chance to do special attack the part in the npc head named "Light" tween it to transprency to 0 (kinda slow but not too slow) and when attack is ended then tween it back to 1 (but faster)

  2. Claude Assistant

    Here's an updated script with damage, cooldown, special attack chance, and head light tweening:

    local NPC = script.Parent
    local Humanoid = NPC:WaitForChild("Humanoid")
    local RootPart = NPC:WaitForChild("HumanoidRootPart")
    local Head = NPC:WaitForChild("Head")
    local Light = Head:WaitForChild("Light")
    
    -- Configuration
    local FOLLOW_RANGE = 50
    local STOP_DISTANCE = 5
    local CHECK_INTERVAL = 0.5
    
    -- Damage and Attack Configuration
    local DAMAGE_AMOUNT = 5
    local ATTACK_COOLDOWN = 2  -- Seconds between attacks
    local SPECIAL_ATTACK_CHANCE = 0.2  -- 20% chance of special attack
    local SPECIAL_ATTACK_DAMAGE = 10
    
    -- Tweening Configuration
    local TweenService = game:GetService("TweenService")
    local LIGHT_FADE_IN_DURATION = 1  -- Slower fade in
    local LIGHT_FADE_OUT_DURATION = 0.5  -- Faster fade out
    
    local lastAttackTime = 0
    
    -- Tween function for light
    local function tweenLight(targetTransparency, duration)
        local tweenInfo = TweenInfo.new(
            duration,
            Enum.EasingStyle.Linear
        )
        
        local tween = TweenService:Create(Light, tweenInfo, {
            Transparency = targetTransparency
        })
        
        tween:Play()
    end
    
    -- Damage function
    local function damagePlayer(player, isSpecialAttack)
        local character = player.Character
        if not character then return end
        
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        if not humanoid then return end
        
        local damage = isSpecialAttack and SPECIAL_ATTACK_DAMAGE or DAMAGE_AMOUNT
        
        -- Tween light for attack
        tweenLight(0, LIGHT_FADE_IN_DURATION)
        
        -- Apply damage
        humanoid:TakeDamage(damage)
        
        -- Reset light after attack
        task.delay(LIGHT_FADE_IN_DURATION, function()
            tweenLight(1, LIGHT_FADE_OUT_DURATION)
        end)
    end
    
    -- Function to find the nearest player within range
    local function findNearestPlayer()
        local nearestPlayer = nil
        local shortestDistance = FOLLOW_RANGE
        
        for _, player in pairs(game.Players:GetPlayers()) do
            if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
                local distance = (player.Character.HumanoidRootPart.Position - RootPart.Position).Magnitude
                
                if distance < shortestDistance then
                    nearestPlayer = player
                    shortestDistance = distance
                end
            end
        end
        
        return nearestPlayer, shortestDistance
    end
    
    -- Collision detection and attack
    local function checkPlayerCollision()
        local currentTime = tick()
        
        if currentTime - lastAttackTime >= ATTACK_COOLDOWN then
            local nearestPlayer, distance = findNearestPlayer()
            
            if nearestPlayer and distance <= STOP_DISTANCE then
                -- Determine if it's a special attack
                local isSpecialAttack = math.random() < SPECIAL_ATTACK_CHANCE
                
                damagePlayer(nearestPlayer, isSpecialAttack)
                lastAttackTime = currentTime
            end
        end
    end
    
    -- Main follow loop
    while true do
        local targetPlayer, distance = findNearestPlayer()
        
        if targetPlayer and distance > STOP_DISTANCE then
            -- Move towards the player
            Humanoid:MoveTo(targetPlayer.Character.HumanoidRootPart.Position)
        else
            -- Stop moving if no player is in range or too close
            Humanoid:MoveTo(RootPart.Position)
        end
        
        -- Check for player collision and potential attack
        checkPlayerCollision()
        
        wait(CHECK_INTERVAL)
    end
    

    To use this script:

    1. Create an NPC model
    2. Add a Part named "Light" inside the NPC's Head
    3. Set the Light part's properties:
      • Make it a small, semi-transparent part
      • Set its Color property to something like white or yellow
      • Position it appropriately inside the head

    Features:

    • NPC follows nearest player
    • 5 damage on touch with cooldown
    • 20% chance of special attack (10 damage)
    • Head light fades in slowly during attack
    • Light resets quickly after attack

    You can easily adjust the configuration variables at the top of the script to fine-tune the NPC's behavior.

    Note: Ensure the script is placed in the NPC model or ServerScriptService, and that the NPC has the correct hierarchy with Humanoid and HumanoidRootPart.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.