My leaderstats won't show for other players and i can't see theirs?
Asked by
6 years ago Edited 6 years ago
So right now i am having an issue that is getting on my nerves.. So when i publish the game and test it with my friends, i can't see their leaderstats, and they can't see mine either, we have been looking for the problem for around 10 minutes and we can't see the problem...
Here's the coin script inside the tool inside the startergear
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local tool = script.Parent |
04 | local player = game.Players |
08 | tool.Activated:Connect( function () |
09 | if Debounce = = false then |
11 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + ( 2 * player.leaderstats.Rebirths.Value) |
And here's the script inside serverscriptservice for leaderboard and data store
01 | local Datastore = game:GetService( "DataStoreService" ):GetDataStore( "pixel-DS3" ) |
03 | game.Players.PlayerAdded:Connect( function (player) |
05 | local Key = "Player-ID:" .. player.userId |
07 | local leaderstats = Instance.new( "Folder" , player) |
08 | leaderstats.Name = "leaderstats" |
10 | local Coins = Instance.new( "NumberValue" , leaderstats) |
13 | local Rebirths = Instance.new( "NumberValue" , leaderstats) |
14 | Rebirths.Name = "Rebirths" |
16 | local GetSave = Datastore:GetAsync(Key) |
19 | Coins.Value = GetSave [ 1 ] |
20 | Rebirths.Value = GetSave [ 2 ] |
21 | print ( "Data loaded for " .. player.Name) |
23 | local Numbers = { Coins.Value, Rebirths.Value } |
24 | Datastore:SetAsync(Key, Numbers) |
25 | print ( "Data Saved for " .. player.Name) |
29 | game.Players.PlayerRemoving:Connect( function (player) |
31 | local Key = "Player-ID:" .. player.userId |
33 | local ValuesToSave = { player.leaderstats.Coins.Value, player.leaderstats.Rebirths.Value } |
35 | Datastore:SetAsync(Key, ValuesToSave) |
37 | print ( "Data Saved for " .. player.Name) |