im trying to make a script so that when you touch a part, it damages you (-17 health) here is what ive tried with what i learned so far, but it doesnt work plz help
repeat game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health = game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health-17 until script.Parent.TouchEnded
Plz help Dx
Put this script inside of a brick/part.
script.Parent.Touched:Connect(function(part) local humanoid = part.Parent:FindFirstChild("Humanoid") -- if the part finds a humanoid, we know it's a player touching the brick if (humanoid ~= nil) then -- if the humanoid exists humanoid:TakeDamage(17) -- damage the humanoid by 17 end end)
script.Parent.Touched:Connect(function(part) CantTouchMe=false local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil and CantTouchMe==false) then humanoid:TakeDamage(17) -- damage the humanoid by 17 CantTouchMe=true wait(3) CantTouchMe=false end end)