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 script that when you click something, It gives you a tool with a cooldown?

No message by the way. I know I'm very demanding, but I really need it so that it has something to do with the ServerStorage. Also, I'm bad at scripting so I don't know here to start.

1 comment

0

use debounce,check if debounce is false, if its false then parent the tool then set debounce as true and wait, then set debounce as false

1 answer

✓ Accepted answer

You'd need a part, a click detector, the tool and a server script

plae the tool in serverstorage the click detector inside the part the script inside the part and this inside the script


local tool = game.ServerStorage.Tool
-- In this case I'm going to assume you're clicking a part
-- This script would go inside of the part
-- The tool can go anywhere, best to go in serverstorage in my op

local part = script.Parent
-- Assuming the part that you need to be clicked is the parent of this script

local debounce = false
-- The variable used to check if a tool has been taken

part.ClickDetector.MouseClick:Connect(function(clicker)
	if debounce == false then
		debounce = true
		coroutine.resume(coroutine.create(function()
			wait(3)
			debounce = false
		end)) -- 3 Seconds then you can get the tool again
		
		local tool2 = tool:Clone()
		tool2.Parent = clicker.Backpack
		
	end	
end)

This is on the server, so only 1 person can take the tool every 3 seconds Player 1 : ** takes tool** Player 2 : "Owo" cant take tool for 3 more seconds

1 comment

0

Thank you

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