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
 

Data Store not working

Previous Thread :: Next Thread 
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 06:46 AM
For some reason, this script is not working...
CashStore = game:GetService('DataStoreService'):GetDataStore('DataStore')
function PlayerEntered(player)
repeat wait() until player.Character
local stats = Instance.new('IntValue')
stats.Parent = player
stats.Name = 'leaderstats'
local cash = Instance.new('IntValue')
cash.Parent = stats
cash.Name = 'Cash'
if CashStore:GetAsync('Points_'..player.Name) ~= nil then
cash.Value = CashStore:GetAsync(player.name)
else cash.Value = 50
end

cash.Changed:connect(function(Val)
CashStore:SetAsync('Points'..player.Name, Val)
end)
end
Report Abuse
fun4nerd4 is not online. fun4nerd4
Joined: 13 Nov 2014
Total Posts: 155
18 Jan 2015 06:52 AM
You only have a certain amount of request per minute!
So when u did this

repeat wait() until

I WAS LIKE!

(X)_(X)
there is your problem!

Here do this!

repeat wait(1) until
--- CODE CODE CODE
end
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
18 Jan 2015 06:55 AM
I didn't see any game.Players.PlayerAdded connect line
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
18 Jan 2015 06:57 AM
The whole function isn't the request. He waited outside of the request to get and send his data, so it shouldn't matter, right?

M'kay.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
18 Jan 2015 06:57 AM
Also, eLunate is right. :)

M'kay.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jan 2015 06:57 AM
i see no reason for the repeat wait() until player.Character, is there a single reference to the character in the script? no
Report Abuse
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 07:03 AM
Alright, thanks for all of your answers, guys!
Report Abuse
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 07:06 AM
Oh no.

It isn't saving the Cash value...
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jan 2015 07:10 AM
and did you test it on studio?
Report Abuse
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 07:11 AM
No, ingame.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jan 2015 07:13 AM
ok
Report Abuse
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 07:14 AM
So how can I fix this??????????
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jan 2015 07:18 AM
this should work:

CashStore = game:GetService('DataStoreService'):GetDataStore('DataStore')
game.Players.PlayerAdded:connect(function(new)
local stats = Instance.new('IntValue',new)
stats.Name = 'leaderstats'
local cash = Instance.new('IntValue',stats)
cash.Name = 'Cash'
if CashStore:GetAsync('Points_'..new.userId) ~= nil then
cash.Value = CashStore:GetAsync('Points_'..new.userId)
else cash.Value = 50
end
end)

game.Players.PlayerRemoving:connect(function(old)
CashStore:SetAsync('Points_'..old.Name, old.leaderstats.Cash.Value)
end)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jan 2015 07:21 AM
lol i didnt change the last part:

game.Players.PlayerRemoving:connect(function(old)
CashStore:SetAsync('Points_'..old.userId, old.leaderstats.Cash.Value)
end)
Report Abuse
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
18 Jan 2015 07:24 AM
Thanks!!!!
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
18 Jan 2015 07:26 AM
Just do like,

game.Players.PlayerRemoving:connect(function(p)
CashStore:SetAsync('Points_'..player.Name, p.leaderstats.Cash.Value);
end)
game.OnClose = function() wait(10) end

And append that to the end lol
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