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

Can someone please make this leaderboard script autosave it self?

Asked by
DashDQ 17
4 years ago
Edited by User#5423 4 years ago

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?

0
edit:- fixed codeblock User#5423 17 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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

Ad

Answer this question