Not quite sure what you're asking, but I've come up with a script.
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local RE = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",10)
Tool.Activated:Connect(function()
RE:FireServer()
end)
local Players = {}
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local PlrTab = Players[player]
if(PlrTab ~= nil) then
local deClick = PlrTab.Clicked
if(deClick == false) then
PlrTab.Clicked = true
print("Clicked!!!, Starting process")
player.Time.Value = true
wait(5)
player.Time.Value = false
print("Stopping Ignoring Clicks for now!")
PlrTab.Clicked = false
else
print("All ready Clicked ignoring...")
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
local Time = Instance.new("BoolValue",plr)
Time.Name = "Time"
Time.Value = false
Players[plr] = {
Clicked = false
}
end)
game.Players.PlayerRemoving:Connect(function(plr)
if(table.find(Players,plr) ~= nil) then
Players[plr] = nil
end
end)
This script logs every player that joins the game and adds your Time bool value to each player. The server side script then waits for a player to activate or click with the tool to change the Time.Value from false to true, as you had, then waits 5 seconds before changing it back to false.
I've made it ignore any other clicks made by a player. Thus stopping the click spam.
I've also allow other players to change their Time bool values without locking up the system until the Clicked Value gets changed back to false.
Let me know if you need anything :)
1 comment
use a for loop with if statements and probably a debounce unless you are asking for something like delay(5,function()