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

i have already made a script to data store but i dont know where to put it?

Asked by 2 years ago

local datastore = game:GetService("DataStoreService") local ds2 = datastore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local cash = Instance.new("IntValue", folder) cash.Name = "Cash"

cash.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsnyc(plr.UserId, cash.Value)

end)

1 answer

Log in to vote
0
Answered by 2 years ago

Put in the ServerScriptService.

The ServerScriptService is basically the go-to when it comes to data saving, as it functions for all players and to have separate data files.

Ad

Answer this question