So I have a Skip Stage Feature in my game. Inside my Skip Stage Script, I first check if the player has enough skips left (which are 3 by default). Whenever the player clicks on the skip stage GUI, if the player has at least 1 skip stage left, we teleport them to the next stage. And 1 is reduced from the limits variable. So now the player has none limits left so they cannot teleport to the next level. But the problem is, if they rejoin the game, they again have 3 skip stage and not 0 or the amount at which they had when they left the game.
So whenever they leave the game, and rejoin, they again have 3 skip stages.
I can't figure out how to save their amount of skip stages left when they leave the game.
Here is my Local Script inside the Skip Stage GUI:
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats"):FindFirstChild("Checkpoint")
local hasLimits = true
local Limits = 3 -- This Limits is the amount of skip stages a player has. It resets to 3 whenever they join the game. Which I don't want.
local maxLevels = game.Workspace.MaxStages.Value -- This is the total amount of stages in the game.
script.Parent.MouseButton1Click:connect(function()
if hasLimits == true then
if Limits ~= 0 then
if leaderstats.Value < maxLevels then
Limits = Limits - 1
leaderstats.Value = leaderstats.Value + 1
if player ~= nil then
if player.Character ~= nil then
if player.Character:FindFirstChild("Humanoid").Health > 0 then
player.Character.HumanoidRootPart.CFrame = game.Workspace.Checkpoints:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
end
end
end
end
else
if player ~= nil then
if player.Character ~= nil then
if player.Character:FindFirstChild("Humanoid").Health > 0 then
player.Character.HumanoidRootPart.CFrame = game.Workspace.Checkpoints:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
end
end
end
end
end
end)
Thanks

1 comment
Maybe add a ModuleScript in ServerStorage for the Limits and then save data using my method?