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

Can someone please make this leaderboard script autosave it self?

Script:

game.Players.PlayerAdded:connect(function(player)
 local folder = Instance.new("Folder",player)
 folder.Name = "leaderstats"
 local currency1 = Instance.new("IntValue",folder)
 currency1.Name = "Cash"
 player.CharacterAdded:connect(function(character)
  character:WaitForChild("Humanoid").Died:connect(function()
  local tag = character.Humanoid:FindFirstChild("creator")
   if tag ~= nil then
    if tag.Value ~= nil then
     currency1.Value = currency1.Value + 10 --This is the reward after the player died.
    end
   end
  end)
 end)
end)

It's basicly an kill script and i don't know how to make it autoave.I even watched tutorials but did not work for me?Can anyone repair my script to autosave the Cash please?

1 comment

0

edit:- fixed codeblock

1 answer

For data persistence in your games, you should use the DataStoreService. It might seem somewhat complicated at first, but its rather simple when you get the hang of it. I'm willing to answer any specific questions about it, but here is some literature to get you started:

https://developer.roblox.com/en-us/api-reference/class/DataStoreService

https://developer.roblox.com/en-us/articles/Saving-Player-Data

https://developer.roblox.com/en-us/articles/Data-store

https://developer.roblox.com/en-us/articles/Datastore-Errors

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