im trying to make a script that damages players when it touches them but for some reason it is broken i checked all of the variables.
1 Like
Instead of using human.Health = human.Health - 5
You can just do
human:TakeDamage(5)
.
1 Like
You should use local debounce = false
instead of using number value.
And do task.wait(waittime)
i just tested with TakeDamage and it did not work
1 Like
Is there a error? If yes, what error says.
1 Like
local waitTime = 1
local Debounce = false
local function Touched(hit)
if not Debounce then
if not hit.Parent:FindFirstChild("Humanoid") then return end
Debounce = true
local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
Humanoid.Health -= 5
wait(waitTime)
Debounce = false
end
end
script.Parent.Touched:Connect(Touched)
1 Like
Thank you that seems to have fixed it!
1 Like
Please mark his reply as a solution, so people know its been solved .
1 Like
I would assume that the issue was that the script you had was very outdated.