Hello developers, I am currently working on a stage system. I have a function which runs everytime a character gets added to workspace, however when the character loads in for the first time it doesn’t work. Here is the script:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Stage = leaderstats:WaitForChild("Stage")
local MaxLevel = Player:WaitForChild("MaxLevel")
local Checkpoints = workspace:WaitForChild("Checkpoints")
Player.CharacterAdded:Connect(function(Character)
-- Character is not detected the first time player joins the game.
Character:WaitForChild("HumanoidRootPart")
Character:MoveTo(Checkpoints[tostring(MaxLevel.Value)].Position)
end)
Thanks in advance.