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

how to disable a function with another function? easy

Ok, so I have 2 functions in this script. When you equip a tool it will wait 1 second and then change the value of a variable and the other functions wait till the value of the variable is changed and it runs. It works now, but It's not professional and very good in my opinion

Any other way of doing this?

Local script Inside tool

local part = game.Workspace.Part
local tool = script.Parent
tool.Equipped:Connect(function()
	wait(1)
	b = 1
	print("ready")
end)
function lol()
	if b == 1 then
	print("gone")
	script.Parent:Destroy()
	end
end
part.TouchEnded:Connect(lol)

I just want 1 second delay for the "lol" function

**Please read what I said before answering **

2 answers

✓ Accepted answer
local part = game.Workspace.Part
local tool = script.Parent
tool.Equipped:Connect(function()
    wait(1)
    b = 1
    print("ready")
end)

local function lol()
    print("HI")
end

delay(.5, lol) 
    if b == 1 then
    print("gone")
    script.Parent:Destroy()
    end
end
part.TouchEnded:Connect(lol)

1 comment

0

Added an extra end. Remove that end on line 18. This code that I gave to you was untested, so it might error out.

Use delay.

Example:

local function lol()
	print("HI")
end

delay(1, lol) -- call on function lol() in 1 second.

1 comment

0

how do you use it in this situation? part.TouchEnded:Connect(lol)

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