local DataStore = game:GetService("DataStoreService"):GetDataStore("StoreName")game.Players.PlayerAdded:connect(function(player) local key = "key-"..player.userId local folder = Instance.new("Folder",player) folder.Name = "leaderstats" local currency1 = Instance.new("Folder",player) folder.Name = "leaderstats" local currency1 = Instance.new("IntValue",folder) currency1.Name = "Money" local save = DataStore:GetAsyncz(key) if save then currency1.Value = save[1] else local load = {currency1.Value} DataStore:SetAsync(key,load) end end)game.Players.PlayerRemoving:connect(function(player) local key = "key-"..player.userId local load = {player.leaderstats:FindFirstChild("Name").Value} DataStore:SetAsync(key,load)Script Number=2 (Which is inside of StarterGui):local player = script.Parent.Parent local leaderboard = player:WaitForChild("leaderstats") local currency1 = leaderboard:WaitForChild("Name")while wait(5) do currency1.Value = currency1.Value + 1 end?
Also if this script have any promblems please do me a favor and tell me thx :) ps: i am new in this scripting thingy so forgive my scripting skills :)
this script in Workspace. Script 1:
local DataStore = game:GetService("DataStoreService"):GetDataStore("StoreName") game.Players.PlayerAdded:connect(function(player) local key = "key-"..(player.userId) local folder = Instance.new("Folder",player) folder.Name = "leaderstats" local currency1 = Instance.new("IntValue",folder) currency1.Name = "Money" local save = DataStore:GetAsync(key) if save then currency1.Value = save[1] else local load = {currency1.Value} DataStore:SetAsync(key,load) end end) game.Players.PlayerRemoving:connect(function(player) local key = "key-"..(player.userId) local Folder = player:WaitForChild("leaderstats") local load = {leaderstats:FindFirstChild("Money").Value} DataStore:SetAsync(key,load) end
this script in StarterGui. Script 2:
local Interval = 5 --put in number. If you set as 5, player get money every 5 seconds. local GetMoney = 20 -- put in number. If you set as 20, player get 20 moneys. local Player = script.Parent.Parent local Folder = Player:WaitForChild("leaderstats") local Currency1 = Folder:WaitForChild("Money") while wait(Interval) do Currency1.Value = Currency1.Value + GetMoney end
Good luck :)
symbol of " -- " will be the comment. Only that line will be a comment. ex)
(script) --Hello, this is Comment (script)