I've made a sword and I have this weird problem were it will do damage to a humanoid when testing my place in studio, but when I start up a server it will only deal damage once and then it stops. Is there some kind of client side v.s server side thing going on? Please Help, thank you.
Damage code located in the Blade of the model:
wait(0.01) CanDamage = true plr = game.Players.LocalPlayer script.Parent.Touched:connect(function(part) local hum = part.Parent:FindFirstChild("Humanoid") if hum then if CanDamage == true and script.Parent.Parent.Swinging.Value == true then CanDamage = false hum:TakeDamage(10) plr.swordlvl.Value = plr.swordlvl.Value + 2 wait(0.8) CanDamage = true end end end)
You wrote the script Inefficiently, and I can see why
wait(0.01) CanDamage = true plr = game.Players.LocalPlayer script.Parent.Touched:connect(function(hum) -- Changed "part" to "hum" -- local hum = part.Parent:FindFirstChild("Humanoid") Delete this if hum and hum.Parent:FindFirstChild("Humanoid") then -- "hum" is the Player who touched the part/Sword. if CanDamage == true and script.Parent.Parent.Swinging.Value == true then CanDamage = false hum.Parent.Humanoid:TakeDamage(10) -- I forgot to add the "Parent.Humanoid" part after "hum" plr.swordlvl.Value = plr.swordlvl.Value + 2 wait(0.8) CanDamage = true end end end)