generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Works but not how it's suppose to

Previous Thread :: Next Thread 
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
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
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
19 Nov 2014 11:45 PM
Bump...
Report Abuse
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
20 Nov 2014 12:18 AM
...
Report Abuse
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
20 Nov 2014 02:13 AM
No one likes to help when it comes to DataStore....
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
20 Nov 2014 07:49 AM
Are you sure you're adding back the saved value when the player joins?
Report Abuse
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image