Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How can I make debounce true when you die?

Asked by 3 days ago
local debounce = true 

local function OnTouched(part)
    if debounce then
    --script
        debounce = false 
        wait(10000000000)
        debounce = true
    end
end
script.Parent.Touched:connect(OnTouched)

how can I make the debounce true when you die? I tried to do this:

local debounce = true 

local function OnTouched(part)
    if debounce then
    --script
        debounce = false 
        wait(10000000000)
        debounce = true
    end
end
script.Parent.Touched:connect(OnTouched)

if humanoid.Health == 0 then
debounce = true
end

but it didnt work can someone help me?

0
When the character dies, it immediately replaces the character along with its children. That's why you can't get the debounce working. Dovydas1118 972 — 3d
0
What??? It doesn't work because (assuming you actually set humanoid) that if statement only runs once it's not gonna constantly check. You need to use Humanoid.Died farrizbb 460 — 3d

1 answer

Log in to vote
0
Answered by 3 days ago
Edited 3 days ago

Here is the exact script you need:

debounce = true

function ontouched(part)
    local Humanoid = part.Parent:FindFirstChild("Humanoid")
    if Humanoid ~= nil then

        humanoid.Died:Connect(function()
            --This will run whenever the humanoid dies
            debounce = false -- This will set the debounce to false
        end)

    end
end

script.Parent.Touched:Connect(ontouched)
Ad

Answer this question