I made leaderstats but you can only see your stats, the other players stats is always at 0
I don't know why this is happening. any help?
Filtering enabled is on btw
local datastore = game:GetService("DataStoreService")
local mydata = datastore:GetDataStore("SlapsPoints")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue",leaderstats)
money.Name = "SlapPoints"
local data
local success, errormessage = pcall(function()
data = mydata:GetAsync(player.UserId)
end)
if success then
print("Data collected")
money.Value = data
else
print("New player")
money.Value = 0
print("Possible error")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data
local success, errormessage = pcall(function()
data = mydata:SetAsync(player.UserId, player.leaderstats.SlapPoints.Value)
end)
if success then
print("Saved!")
else
print("Error")
end
end)SlapStorage:SetAsync(player.UserId,slaps.Value)
end
end)

4 comments
what script type is this being ran on
Server Script
If that is happening, then the script is a local script. Considering you're using the playeradded event, you don't need it to be a local script. Basically, convert the local script into a noromal script.
It isn't a local script