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

I'm tryna save data and make others be able to see it. Can anyone help?

I am trying to make it so data saves and other people can see it the leaderboard stats of other players.

ClickData = game:GetService("DataStoreService"):GetDataStore("ClickData3825")
-- You can put anything here
RebirthData = game:GetService("DataStoreService"):GetDataStore("RebirthData5936")
-- and here

game.Players.PlayerAdded:Connect(function(plr)
local LB = Instance.new("IntValue", plr)

LB.Name = "leaderstats"

local p = Instance.new("IntValue", LB)
p.Name = "Clicks"
p.Value = ClickData:GetAsync(plr.userId) or 0

local r = Instance.new("IntValue", LB)
r.Name = "Rebirths"
r.Value = RebirthData:GetAsync(plr.userId) or 0

LB.Parent = plr
p.Parent = LB
r.Parent = LB
end)

game.Players.PlayerRemoving:Connect(function(plr)
ClickData:SetAsync(plr.userId, plr.leaderstats.Clicks.Value)
RebirthData:SetAsync(plr.userId, plr.leaderstats.Rebirths.Value)
end)

5 comments

0

It should work. Attempt turning on access to the api service.

0

In game settings.

0

We have the API service on already

0

people can see it, its the server. server can only have access to datastore. either you disable the leaderboard on a localscript

0

try not testing it in studio, try testing it in game btw

1 answer

Replace every 'userId' to 'UserId'

In line 13

p.Value = ClickData:GetAsync(plr.UserId) or 0

In line 17

r.Value = RebirthData:GetAsync(plr.UserId) or 0

In line 25

ClickData:SetAsync(plr.UserId, plr.leaderstats.Clicks.Value)

In line 26

RebirthData:SetAsync(plr.UserId, plr.leaderstats.Rebirths.Value)

I'm sure userId doesn't exist but UserId does

4 comments

0

i did that and we still can’t see eachothers stats

0

reeeeebot10 is working on it with me btw

0

look at my other comment

0

its deprecated... doesnt mean that it wont work if you use it

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