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

How to make a wait delay whenever a player unequips a tool?

Hello! I am trying to make a tool delay, to prevent lag from spammers. I've been working on this for almost 2 weeks, and I'm having no luck. If you know how to make a delay, please help me out! I'm losing my mind still working on this! Thanks for any help!

Here's the script I've been working on:

local tool = script.Parent
toolfolder = game.ServerStorage:WaitForChild("Toolfolder")


tool.Unequipped:Connect(function()
	tool.Parent = toolfolder
	wait(1)
	tool.Parent = game.Players.LocalPlayer.Backpack
end)

1 answer

✓ Accepted answer

There's no one way to make a delay. Personally, if I were you I'd make the delay when the player equips the tool using a debounce. Like so:

local debounce = false

tool.Equipped:Connect(function()
	debounce = true
	wait(2)
	debounce = false
end)

tool.Activate:Connect(function()
	if debounce == true then return end
	debounce = true
	-- tool code
	wait(2)
	debounce = false
end

I'm not giving you code here, I'm giving you an idea which hopefully you can implement into your tool.

2 comments

0

Thanks a bunch!

0

I hope you don't think I'm being rude. It's hard to answer questions like these because there's lots of things you need to factor in and the fact there's not one method to make something.

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