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

How to add time between giving item?

Hi, I made script which can give item by click, but how can I add time between taking it again from SAME PLAYER?

local tool = game.ServerStorage.Tool

script.Parent.ClickDetector.MouseClick:connect (function(plr)
    local klone = tool:clone()
    if klone.Parent ~= plr.Backpack then
        klone.Parent = plr.Backpack
        else
    end
end)

1 answer

✓ Accepted answer

Based on your description, I think this is similar to what you're looking for:


local Tool = game:GetService("ServerStorage").Tool

local Debounces = {}
local Time = 10 -- in seconds.

script.Parent.ClickDetector.MouseClick:connect(function(Player)
	if Debounces[Player.Name] then
		print(Player.Name .. " is not eligible for a tool yet.")
		return
	end
	local Backpack = Player:FindFirstChild("Backpack")
	if Backpack then
		local Check = Backpack:FindFirstChild(Tool.Name) or Player.Character:FindFirstChild(Tool.Name)
		if not Check then
			Debounces[Player.Name] = true
			Tool:Clone().Parent = Backpack
			print(Player.Name .. " has recieved the tool: " .. Tool.Name)
			wait(Time)
			Debounces[Player.Name] = nil
			print(Player.Name .. "can now get another tool.")
		end
	end
end)
  1. This will not give the player the tool if she/he already has it.

  2. If you don't have it and try to get it before x seconds is passed, you will not be able to get it.

1 comment

0

Nice, very good script. Thank you!

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