Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

leaderstats is not a valid member of player?

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!

1 comment

0

MoveTo means it will walk the player to the position lol.

2 answers

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.

1 comment

0

Don't forget the ")" at line 3. Use "workspace:FindFirstChild("Stage")..player:WaitForChild("leaderstats").Level.Value).Position".

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.

1 comment

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.