This is a datastore (That works 100%) is there a way for the datastore to insert a model into the player like it does with leaderstats, and save the weapons that are inputted into starter gear while in game? There are 2 scripts to this ill put them both down. Value in main script is a bool value.
MainScript:
local DataStore = game:GetService("DataStoreService"):GetDataStore("MoneyStore")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Name = "Points"
money.Value = 50
if script.UseDataStore.Value == true then
local key = "user_" ..player.userId
local savedValues = DataStore:GetAsync(key)
local valuesToSave = {money.Value}
if savedValues then
-- Save format: {money}
money.Value = savedValues[1]
else
DataStore:SetAsync(key, valuesToSave)
end
game.Players.PlayerRemoving:connect(function(player)
local money = player.leaderstats.Points
local valuesToSave = {money.Value}
local key = "user_" ..player.userId
DataStore:SetAsync(key, valuesToSave)
end)
end
end)
