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

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

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.

2 comments

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.

0

ugh fineeee

1 answer

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)

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