Why doesn’t player.CharacterAdded work? There’s 0 errors in the output for it, and I’ve tried it in both studio and the roblox client. Here’s the code if you’re wondering.
It doesn’t work this way cause its trying to teleport the player as soon as he spawns, it happened to me before and that was the only fix, its not because of you.
Sorry for making this more complicated but this isn’t a good solution due to if the server lagging to some extent this wait() won’t be enough to wait for the character instance to load resulting in failure especially if this runs when a server was just created and a player joined. A more practical way to solving this would to use :WaitForChild() instead.
Another cause of the issue may be that previous code above is yielding the event also resulting it to not run.
It’s almost as if the CharacterAdded event doesn’t fire at all. I think I could possibly be because I’m calling a function that uses GetAsync() which is a yielding function
Adding on to this I finally figured it out, the issue was that the GetAsync() function in my data loading function was hindering CharacterAdded because it was called BEFORE CharacterAdded. This is because it’s a yielding call. In order to fix this, you can create the Stages Variable using WaitForChild() instead of wait()
player.CharacterAdded:Connect(function(character)
local Stages = leaderstats:WaitForChild("Stages") -- this will wait until the data is initalized
character.CFrame = workspace.Checkpoints["Checkpoint" .. Stages.Value].CFrame
end)
LoadData() -- just the function that gets the data that has a GetAsync() function in it.
Made this post just to help anyone who runs into the same issue. Peace.