I made an obby so I started to work on leaderstats
then the auto-save using DataStoreService
and 3 DataStores (LevelSave, StageSave and StartScreenStartSave). But thats not the problem. The problem is the SaveTeleporter. So when you rejoin it has your save file via UserId. The SaveTeleporter gets access to the saved file (in player.leaderstats) and finds a part by the name of "Stage"..player.leaderstats.Level.Value.
The Script:
game.Players.PlayerAdded:Connect(function(player) workspace:FindFirstChild(player.Name).Position = workspace:FindFirstChild("Stage"..player.leaderstats.Level.Value).Position end)
I also tried
game.Players.PlayerAdded:Connect(function(player) workspace:FindFirstChild(player.Name):MoveTo(workspace:FindFirstChild("Stage" ..player.leaderstats.Level.Value).Position) end)
But both of these don't work.
It just says the same error on Output
:
09:24:28.752 - leaderstats is not a valid member of Player
I want a script that gets access to player.leaderstats.Level.Value and teleports to where the player left from Stage 1 - Stage 13 in workspace
.
Any help would be appreciated!
Try using WaitForChild
as it waits for an instance to get loaded.
game.Players.PlayerAdded:Connect(function(player) workspace:FindFirstChild(player.Name).Position = workspace:FindFirstChild("Stage"..player:WaitForChild("leaderstats").Level.Value).Position end)
game.Players.PlayerAdded:Connect(function(player) workspace:FindFirstChild(player.Name):MoveTo(workspace:FindFirstChild("Stage" ..player:WaitForChild("leaderstats").Level.Value).Position) end)
It should work and tell me if you get an infinite yield.
Trust me it is way harder than that to do an obby. But if nobody answers this by a few hours, I will show you the script I have used. I can't now because I am not on PC.