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

How do I make cash that saves and auto gives out for being in game and spend the cash?

Asked by
ZapCC 0
6 years ago

Ok, I have tried multiple tutorials I have tried this

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 = "Name"

 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
?~~~~~~~~~~~~~~~~~
And then I put this under the Starter GUI

local DateStore = 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 = "Currency Name Here" end ~~~~~~~~~~~~~~~~~ Also, could you maybe put your discord in answer so I could contact and we could speak live also I really want to know after I make the cash and auto save and it auto give's to you how do I spend the cash or add a script to spend a cash by say walking into a door or something that will trigger it off! Thanks!

Sincerely, ZapCC ROBLOX Developer,User!

Answer this question