Hello there im very clueless and i dunno what to put here so yea
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local Power = Instance.new("IntValue",leaderstats) Power.Name = "Power" Power.Value = 0 local Money = Instance.new("IntValue",leaderstats) Money.Name = "Energy" Money.Value = 0
end)
how do i save this?
You need to use the DataStore Service
Here is the script.
local players = game:GetService("Players") local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("PowerValueSaver") --Runs power server local ds2 = datastore:GetDataStore("MoneyValueSaver") --Runs money server players.PlayerAdded:connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local Power = Instance.new("IntValue") Power.Name = "Power" Power.Parent = plr.leaderstats Power.Value = ds1:GetAsync(plr.UserId) or 0 --Checks if power is saved or sets to 0 ds1:SetAsync(plr.UserId, Power.Value) --Saves power local Money = Instance.new("IntValue") Money.Name = "Energy" Money.Parent = plr.leaderstats Money.Value = ds2:GetAsync(plr.UserId) or 0 --Checks if Money is saved or sets to 0 ds2:SetAsync(plr.UserId, Money.Value) -- Saves Money Power.Changed:connect(function() ds1:SetAsync(plr.UserId, Power.Value) --Saves when Power is changed end) Money.Changed:connect(function() ds2:SetAsync(plr.UserId, Money.Value) --Saves when Money is changed end) end)