Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UI = script.Parent
- local player = game.Players.LocalPlayer
- local checkpoints = workspace:WaitForChild("Checkpoints")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Teleport = ReplicatedStorage:WaitForChild("Teleport")
- local Level = UI:WaitForChild("Stage")
- local Previous = UI:WaitForChild("Previous")
- local Next = UI:WaitForChild("Next")
- local CurrentValue = UI:WaitForChild("CurrentStage")
- local function previousLevel()
- if CurrentValue.Value ~= 1 then
- CurrentValue.Value = CurrentValue.Value - 1
- Level.Text = CurrentValue.Value
- Teleport:FireServer(checkpoints:GetChildren()[CurrentValue.Value])
- end
- end
- local function nextLevel()
- if CurrentValue.Value ~= #checkpoints:GetChildren() then
- if (CurrentValue.Value + 1) <= player.leaderstats.Stage.Value then
- CurrentValue.Value = CurrentValue.Value + 1
- Level.Text = CurrentValue.Value
- Teleport:FireServer(checkpoints:GetChildren()[CurrentValue.Value])
- end
- end
- end
- Previous.MouseButton1Click:Connect(function()
- previousLevel()
- end)
- Next.MouseButton1Click:Connect(function()
- nextLevel()
- end)
- CurrentValue.Value = player:WaitForChild("leaderstats").Stage.Value
- Level.Text = CurrentValue.Value
- player.leaderstats.Stage:GetPropertyChangedSignal("Value"):Connect(function()
- CurrentValue.Value = player.leaderstats.Stage.Value
- Level.Text = CurrentValue.Value
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement