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

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

Asked by 2 years ago

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)
0
It should work. Attempt turning on access to the api service. AProgrammR 398 — 2y
0
In game settings. AProgrammR 398 — 2y
0
We have the API service on already urbanninja2442 0 — 2y
0
people can see it, its the server. server can only have access to datastore. either you disable the leaderboard on a localscript AProgrammR 398 — 2y
0
try not testing it in studio, try testing it in game btw AProgrammR 398 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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

0
i did that and we still can’t see eachothers stats reeeeebot10 2 — 2y
0
reeeeebot10 is working on it with me btw urbanninja2442 0 — 2y
0
look at my other comment AProgrammR 398 — 2y
0
its deprecated... doesnt mean that it wont work if you use it greatneil80 2647 — 2y
Ad

Answer this question