Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make debounce true when you die?

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?

2 comments

0

When the character dies, it immediately replaces the character along with its children. That's why you can't get the debounce working.

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

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.