Okay so basically, I have this script in serverscriptservice:
game.ReplicatedStorage.LightSaberEvent.OnServerEvent:Connect(function(player) player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100000000 workspace[player.Name].LightSaberv1.ManualActivationOnly = true wait(0.3) workspace[player.Name].LightSaberv1.ManualActivationOnly = false end)
and I wanna make an autoclicker cooldown for 5 seconds. The RemoteEvent is: LightSaberEvent
and the replicated storage local script is
script.LightSaberEvent.OnServerEvent:Connect(function() game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 100000000 end)
Basically the same thing. The local script for the tool of the lightsaber is :
player = game.Players.LocalPlayer script.Parent.Activated:Connect(function() game.ReplicatedStorage.LightSaberEvent:FireServer() end) script.Parent.Equipped:Connect(function() game.Workspace[player.Name].LightSaberv1.ManualActivationOnly = false end) script.Parent.Unequipped:Connect(function() game.Players[player.Name].Backpack.LightSaberv1.ManualActivationOnly = true end)
Please help me I'm lost in trying to make an auto clicker cooldown script.
player = game.Players.LocalPlayer local debounce = 5 local canUse = true script.Parent.Activated:Connect(function() if canUse == true then -- Checking to see if the user can use there tool game.ReplicatedStorage.LightSaberEvent:FireServer() canUse = false -- Making it so the user can't use it spawn(function() -- Making a seperate thread, this way the waiting isn't delayed wait(debounce) -- Waiting our 5 seconds (seen via debounce) canUse = true -- Making it so the user can activate there tool again end) end end) script.Parent.Equipped:Connect(function() game.Workspace[player.Name].LightSaberv1.ManualActivationOnly = false end) script.Parent.Unequipped:Connect(function() game.Players[player.Name].Backpack.LightSaberv1.ManualActivationOnly = true end)