So i am making an obby with gui navigation to move between stages, and I encountered a problem.
I don’t really know how to move the player to the specific part that they are going to.
current code and plan:
local Player = game:GetService("Players").LocalPlayer
local rightbutton = Player.PlayerGui.LevelGui.Main.Right
local levelchange = Player.PlayerGui.LevelGui.Main.level
local lastStage = Player.leaderstats.Stage
local checkpointWord = "Checkpoint"
rightbutton.MouseButton1Click:Connect(function()
if (levelchange == lastStage) then
return "error, last stage currently unlocked"
else
local nextPoint = levelchange + 1
local placeToMove = checkpointWord .. nextPoint
local partToMove = game.Workspace.placeToMove
Player.CFrame = partToMove.CFrame --is this how i do it?
end
end)
my checkpoints are called "Checkpoint"x, where x is the number. Example: “Checkpoint2”
i’m still new to scripting, so the answer may be obvious, but I don’t know what to do.
i just tested the script, it seems to not want to teleport me?
local Player = game:GetService("Players").LocalPlayer
local rightbutton = Player.PlayerGui.LevelGui.Main.Right
local levelchange = Player.PlayerGui.LevelGui.Main.level
local lastStage = Player.leaderstats.Stage
local checkpointWord = "Checkpoint"
rightbutton.MouseButton1Click:Connect(function()
if (levelchange == lastStage) then
print("error")
return "error, last stage currently unlocked"
else
print("hello?") -- doesnt print this
local nextPoint = levelchange + 1
local placeToMove = checkpointWord .. nextPoint
local partToMove = workspace:FindFirstChild(placeToMove)
Player.Character.HumanoidRootPart.CFrame = partToMove.Cframe
end
end)