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

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tool = script.Parent

local player = game.Players

local Debounce = false
 
tool.Activated:Connect(function()
    if Debounce == false then
        Debounce = true
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + (2 * player.leaderstats.Rebirths.Value)
        wait(0.001)
        Debounce = false
    end
end)

And here's the script inside serverscriptservice for leaderboard and data store

local Datastore = game:GetService("DataStoreService"):GetDataStore("pixel-DS3")
 
game.Players.PlayerAdded:Connect(function(player)
   
    local Key = "Player-ID:" .. player.userId
   
    local leaderstats = Instance.new("Folder", player)
    leaderstats.Name = "leaderstats"
   
    local Coins = Instance.new("NumberValue", leaderstats)
    Coins.Name = "Coins"
   
    local Rebirths = Instance.new("NumberValue", leaderstats)
    Rebirths.Name = "Rebirths"
   
    local GetSave = Datastore:GetAsync(Key)
   
    if GetSave then
        Coins.Value = GetSave[1]
        Rebirths.Value = GetSave[2]
        print("Data loaded for " .. player.Name)
    else
        local Numbers = {Coins.Value, Rebirths.Value}
        Datastore:SetAsync(Key, Numbers)
        print("Data Saved for " .. player.Name)
    end
end)
 
game.Players.PlayerRemoving:Connect(function(player)
   
    local Key = "Player-ID:" .. player.userId
   
    local ValuesToSave = {player.leaderstats.Coins.Value, player.leaderstats.Rebirths.Value}
   
    Datastore:SetAsync(Key, ValuesToSave)
   
    print("Data Saved for " .. player.Name)
end)

3 comments

1

If you are changing something from the client, it won't be visible to other clients because of filtering enabled.

1

This is a situation where you would need remote events. Also, wait(0.001) is smaller than the default waiting time. If you're gonna have a wait, either use the default wait(), or do wait(somenumberabovedefaultwaittime).

1

also, in the first script, the player variable is referring to the players service, not an individual player