Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

leaderstats is not a valid member of player?

Asked by 4 years ago

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!

0
MoveTo means it will walk the player to the position lol. PrismaticFruits 842 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

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.

0
Don't forget the ")" at line 3. Use "workspace:FindFirstChild("Stage")..player:WaitForChild("leaderstats").Level.Value).Position". youtubemasterWOW 2741 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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.

0
ok Filip100012 58 — 4y

Answer this question