I’ve been trying to make a proper working system for a forwards and backwards gui but so far i have been unsuccessful.
backwards remote script:
Runcontext: Server
game.ReplicatedStorage.back.OnServerEvent:Connect(function(plr)
if plr.back.Value == 0 then
plr.back.Value = 1
else
plr.back.Value = plr.back.Value+1
end
end)
Forwards remote script:
game.ReplicatedStorage.forward.OnServerEvent:Connect(function(plr)
print("forward passed test")
plr.back.Value = plr.back.Value-1
end)
Backwards script so far:
local Stages = workspace:WaitForChild("Stages")
script.Parent.MouseButton1Click:Connect(function(plr)
wait(0.5)
local playerback = script.Parent.Parent.Parent.Parent.Parent.back.Value
game.ReplicatedStorage.back:FireServer(plr)
local playerCheckpoint = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Stage.Value
print(playerCheckpoint)
if playerCheckpoint > 1 then -- Ensure the player is not on the first checkpoint
local teleportCheckpoint = game.Workspace.Stages:FindFirstChild(tostring(playerCheckpoint - 1))
print(teleportCheckpoint)
if teleportCheckpoint then
script.Parent.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(teleportCheckpoint.Position)+Vector3.new(0,2,0)
end
end
end)
Forward script so far:
local Stages = workspace:WaitForChild("Stages")
local followmeinmerrymeasure
script.Parent.MouseButton1Click:Connect(function(plr)
wait(0.5)
local playerback = script.Parent.Parent.Parent.Parent.Parent.forward.Value
local playerback2 = script.Parent.Parent.Parent.Parent.Parent.back.Value
local playerCheckpoint = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Stage.Value
local playerCheckpoint100 = tonumber(script.Parent.Parent.Parent.Parent.Parent.leaderstats.Stage.Value)
game.ReplicatedStorage.forward:FireServer(plr)
local targetCheckpoint = Stages:FindFirstChild(tostring(playerCheckpoint-playerback2 + 1))
followmeinmerrymeasure = tonumber(targetCheckpoint.Name)
if playerCheckpoint < followmeinmerrymeasure then
return
else
if targetCheckpoint then
script.Parent.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(targetCheckpoint.Position) + Vector3.new(0, 2, 0)
end
end
end)
if any more information is needed, I am very happy to provide as I want to get this finished.