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

Why do I have to jump for the debounce in my kill brick to work?

Asked by
SkiH1gh 14
3 years ago

So lately Ive been trying to make an ocean work so it kills you over time. I have a debounce that is checked when you touch the ocean, if it is false, it will set it to true and damage you (and wait 0.5 seconds to reset debounce to false) but for some reason, you have to jump for it to take damage on you again. I swear I've used this method before and have it work perfectly. Help would be great! (script is serversided, and inside the ocean part (canTouch is on))

local debounce = false

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if debounce == false then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 10

            debounce = true
            wait(0.5)
            debounce = false
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

I'm no roblox physics expert, but the problem here is most likely that a Touched only fires when two moving parts collide. If they are both at a standstill, the event will not fire. Again, I'm no roblox physics expert, so I don't know exactly how to fix this problem, but your best bet would probably be to use a Region3 instead of a Touched event.

Ad

Answer this question