print("Test12")
local Player = game:GetService("Players").LocalPlayer
local rightbutton = Player.PlayerGui.LevelGui.Main.Right
local levelchange = game.Workspace.StageChange
local lastStage = Player.leaderstats.Stage
local checkpointWord = "Checkpoint"
rightbutton.MouseButton1Click:Connect(function()
print("testing")
if (levelchange.Value == lastStage.Value) then
print("error")
return "error, last stage currently unlocked"
else
print("hello?")
local nextPoint = levelchange + 1
local placeToMove = checkpointWord .. nextPoint
local partToMove = workspace:FindFirstChild(placeToMove)
Player.Character.HumanoidRootPart.CFrame = partToMove.Cframe
end
end)
despite all of these prints, none of them seem to work even if I put it in player scripts
I wrote a giant list explaining everything that you made wrong but I accidently deleted it. (Solution✅ would be appreciated)
(if it doesn’t work explain to me what are you trying to do and record a video showing the Explorer and I’ll remake it)
Here is what you supposed to do to make it work
make a script (Not local script) and put it in ServerScriptService
Paste this code inside
game.Players.PlayerAdded:Connect(function(plr)
Player = plr
end)
local levelchange = game.Workspace:WaitForChild("StageChange")
local lastStage = Player.leaderstats:WaitForChild("Stage")
local rightbutton = Player.PlayerGui.LevelGui.Main.Right
rightbutton.MouseButton1Click:Connect(function()
if (levelchange.Value == lastStage.Value) then
return "error, last stage currently unlocked"
else
local nextPoint = levelchange.Value + 1
local placeToMove = "Checkpoint" .. nextPoint
local partToMove = workspace:FindFirstChild(placeToMove)
Player.Character.HumanoidRootPart.CFrame = partToMove.CFrame
end
end)
my plan is to make the character move to the part refereced as partToMove when a button is clicked, i want to know the difference between doing workspace.StageChange and workspace:WaitForChild(“StageChange”).
Oh, Player is nil for some reason. look on line 7, it gives an error (its because you never actually declare a Player variable, ill rewrite the script to let you do that)
--LOCAL SCRIPT INSIDE STARTERPLAYERSCRIPTS
local Player = game.Players.LocalPlayer
local levelchange = game.Workspace:WaitForChild("StageChange")
local lastStage = Player.leaderstats:WaitForChild("Stage")
local rightbutton = Player.PlayerGui.LevelGui.Main.Right
rightbutton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.ChangeStageEvent:FireServer(lastStage, levelchange)
end)
--SERVER SCRIPT INSIDE SERVERSCRIPTSERVICE
game.ReplicatedStorage.ChangeStageEvent.OnServerEvent:Connect(function(player, lastStage, levelChange)
local nextPoint = levelChange + 1
local placeToMove = "Checkpoint" .. nextPoint
local partToMove = workspace:FindFirstChild(placeToMove)
player.Character.HumanoidRootPart.CFrame = partToMove.CFrame
end)
this might be wrong or not work, because i cannot test this inside a copy of the place. im basing this off knowledge of your workspace and the script