Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

script not always updating string value or damaging player with filtering enabled? EDITED

Asked by 7 years ago
Edited 7 years ago

The goal of this script is to allow a player to swing a sword, and when they make contact with the player deal 15 damage, and when they kill said a player, a string value will be updated with the name of the player killed.

the issue is that even when a player is killed, the value is not always updated, and seems to only function in random intervals. String value and script are both in the sword, which is part within the character.

Edit - sword will not damage player at all with filtering enabled turned on.

Script

local Obj = script.Parent

Obj.Touched:connect(function(Hit)
    if Hit.Parent:findFirstChild("Humanoid") then
        Hit.Parent.Humanoid:TakeDamage(10)
        if Hit.Parent.Humanoid.Health <= 0 then
            script.Parent.Killed.Value = Hit.Parent.Name    
        end
    end
end)

Answer this question