Im making Guess the anime game and i have this infinite skips gamepass skips there is way to improve this script? and how do i add cooldown to this script. Thanks
checkpoints(its not the full script):
local Checkpoints = workspace:WaitForChild("Checkpoints")
local Skip = ReplicatedStorage:WaitForChild("Skip")
local players = game.Players:GetPlayers()
local finish = 0
Skip.OnServerInvoke = function(player)
local players = game.Players:GetPlayers()
local finish = 0
for i=1, #players do
if finish == 0 then
finish = 1
players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
players[i].Character:MoveTo(Checkpoints:FindFirstChild(players[i].leaderstats.Stage.Value).Position)
end
end
end
local script:
local TextButton = script.Parent
local Checkpoints = workspace:WaitForChild("Checkpoints")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local StageLeaderstat = player:WaitForChild("leaderstats"):WaitForChild("Stage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Skip = ReplicatedStorage:WaitForChild("Skip")
TextButton.MouseButton1Click:Connect(function()
local Response = Skip:InvokeServer()
end)