Script:
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local folder = Instance.new( "Folder" ,player) |
03 | folder.Name = "leaderstats" |
04 | local currency 1 = Instance.new( "IntValue" ,folder) |
05 | currency 1. Name = "Cash" |
06 | player.CharacterAdded:connect( function (character) |
07 | character:WaitForChild( "Humanoid" ).Died:connect( function () |
08 | local tag = character.Humanoid:FindFirstChild( "creator" ) |
09 | if tag ~ = nil then |
10 | if tag.Value ~ = nil then |
11 | currency 1. Value = currency 1. Value + 10 --This is the reward after the player died. |
12 | end |
13 | end |
14 | end ) |
15 | end ) |
16 | 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?
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