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

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

0
Thanks a bunch! mymatevince1215 9 — 3y
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. radiant_Light203 1166 — 3y
Ad

Answer this question