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

Leaderboard system cash ?

Asked by 6 years ago
Edited 6 years ago

Hello, i need your help ! i want add a system of cash per second in my roblox server, i have make this script but i don't know how i can place the line for give cash.

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player)
 local leader = Instance.new("Folder",player)
 leader.Name = "leaderstats"
 local Cash = Instance.new("IntValue",leader)
 Cash.Name = "Cash"
 Cash.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, Cash.Value)
 Cash.Changed:connect(function()
  ds:SetAsync(player.UserId, Cash.Value)
 end)
end)


game.Players.PlayerRemoving:connect(function(player)
 ds:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)

I have tried to place this after and before the code, but not working..

while wait (1) do

Cash.Value = Cash.Value + 1

2 answers

Log in to vote
0
Answered by
Qawstar 32
6 years ago

Hai!

Make a new script and place it under the main script, so the script which you have writed here is the parent! :)

SCRIPT!:

while wait(1) do
    game.Players.LocalPlayer.leaderstats["YourCurrencyName"].Value=game.Players.LocalPlayer.leaderstats["YourCurrencyName"].Value+1
end 
0
Thank you very much ! i have one more a little question ^^ its necessary to place this into serverscriptservice or in workspace ? Thorngard 4 — 6y
0
You decide, its really the same. Oficcer_F 207 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I have read your script under my main script, it's good in roblox studio but in roblox game the cash stay in 0, idea ?

Answer this question