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

Keeping play score?

I'm trying to make a game sorta like cookie clicker, and was wondering, how do you set a text that only the player can see of the players points (Cookies if you like)?

1 answer

✓ Accepted answer

This is Data Persistence. It saves everything on the leaderboard.



function onPlayerEntered(player)
wait()-- Change to wait for player longer.
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end

function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

5 comments

0

Woops, i wrote my Question wrong.. >.< re read it. Sorry. XD

0

Ew, data persistence. It's all about Data Store now.

0

I don't understand the question now

0

Example: On a cookie clicker game there is a Text that shows your cookies. That's what I'm trying to do. :p

0

Oh on the screen. Well I am not sure about that

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