Hey there so i’m scripting an obby and CharacterAdded won’t seem to work. Here’s the script
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local CheckPoints = Workspace.CheckPoints
function PlayerAdded(player)
print(player, "loaded")
local leaderstats = Instance.new("Folder")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"
local Stage = Instance.new("IntValue")
Stage.Parent = leaderstats
Stage.Name = "Stage"
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
character:MoveTo(CheckPoints[Stage.Value].Position)
humanoid.Touched:Connect(function(hit)
if hit.Parent == CheckPoints then
if tonumber(hit.Name) == Stage.Value + 1 then
Stage.Value = Stage.Value + 1
end
end
end)
end
end
Players.PlayerAdded:Connect(PlayerAdded)
The problem is the player.CharacterAdded line and I’m wondering how I could fix this.