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

I am a noob scripter, and I need to know how to create a data save script?

Asked by 3 years ago

So, I am a noob at scripting and I have no idea how to script a data save script. But, I need one for my game.

0
you can't simply use "im noob at scripting" as an excuse to not need to any work trying to create what you wanna create, you can try searching data store service, or a youtube tutorial. NGC4637 602 — 3y
0
ugh fineeee TheStageGuyYT 19 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
local dataStore = game:GetService("DataStoreService"):GetDataStore("MoneyData")

starterMoney = 0


game.Players.PlayerAdded:Connect(function(plr)

 local leaderstats = Instance.new("Folder")
 leaderstats.Name = "leaderstats"
 leaderstats.Parent = plr

 local money = Instance.new("IntValue")
 money.Name = "Money" --Put your currency
 money.Value = dataStore:GetAsync(plr.UserId) or starterMoney
 money.Parent = leaderstats

end)

game.Players.PlayerRemoving:Connect(function(plr)

 dataStore:SetAsync(plr.UserId, plr.leaderstats.Money.Value)

end)
Ad

Answer this question