I have been trying to make a delay between damage but for some reason it (almost) instantly kills the player, ignoring the delay.
Anything to replace? Something im missing? let me know
local lavadelay = script.parent.lavasettings.lavadmgdelay.value
local lavadmg = script.parent.lavasettings.lavadmgdelay.value
local function BurnPlayer(otherPart) --detects part touched
local humanoid = otherPart.Parent:FindFirstChildOfClass("Humanoid")--detects if part touched is a player part
while otherPart do
wait(lavadelay)
otherPart.Parent.Humanoid:TakeDamage(lavadmg)
wait(lavadelay)
end
end
If your damage isn’t 100 then I think the problem is you’re calling this function every time the part is touched > so that means the while loop would be overlapping I would think. Try taking out the loop and just adding a set value for damage > then adding a variable and checking the variable on and off with the delay time.
That function gets called every time the player touches the part. wait() yields the current thread x amount of seconds, it doesn’t prevent the same function from running again. What you want is a debounce.