|
| 19 Nov 2014 10:48 PM |
It saves 5 each visit not matter how much I add(Click the gui) it will only save 5 per visit.
local ds = game:GetService("DataStoreService"):GetGlobalDataStore() sp = script.Parent Cash = ds:GetAsync("CashV2") if Cash == nil then Cash = 0 end
sp.Frame.Shop.Guns.One.MouseButton1Click:connect(function() Cash = Cash + 5 ds:SetAsync("CashV2", Cash) end)
while true do sp.Frame.Shop.Cash.Text = Cash wait() end
game.Players.PlayerRemoving:connect(function(player) ds:SetAsync("CashV2", Cash) end) |
|
|
| Report Abuse |
|
|
|
| 19 Nov 2014 10:51 PM |
| The while true do statement is bugging up your code. It never moves on from there. How about just updating the text when someone clicks the gun function? |
|
|
| Report Abuse |
|
|
|
| 19 Nov 2014 10:59 PM |
I know for a fact that's not the problem but just to show you, the code below still does the same thing.
local ds = game:GetService("DataStoreService"):GetGlobalDataStore() sp = script.Parent Cash = ds:GetAsync("CashV2") if Cash == nil then Cash = 0 end sp.Frame.Shop.Cash.Text = Cash
sp.Frame.Shop.Guns.One.MouseButton1Click:connect(function() Cash = Cash + 5 sp.Frame.Shop.Cash.Text = Cash ds:SetAsync("CashV2", Cash) end)
game.Players.PlayerRemoving:connect(function(player) ds:SetAsync("CashV2", Cash) end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 20 Nov 2014 02:13 AM |
| No one likes to help when it comes to DataStore.... |
|
|
| Report Abuse |
|
|
|
| 20 Nov 2014 07:49 AM |
| Are you sure you're adding back the saved value when the player joins? |
|
|
| Report Abuse |
|
|
|
| 20 Nov 2014 04:23 PM |
Cash = ds:GetAsync("CashV2")
Like I said it works, but lets say you visit the game one and click the gui. It'll add 5 every time you click it. Well it only saves the first click on every visit. |
|
|
| Report Abuse |
|
|