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 » Scripting Helpers
Home Search
 

Re: what is wrong with this?

Previous Thread :: Next Thread 
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:14 AM
winneraward = 1
for i=1, #a do
if a[i].TeamColor == BrickColor.new("Really blue") then
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value + winneraward
print(a[i].Name.." Has "..a[i].leaderstats.Credits.Value.." Credits")
store = game:GetService("DataStoreService"):GetDataStore("LeaderBoard")
local child= a[i].leaderstats:GetChildren()
for i=1, #child do
child[i].Value= store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
end
wait(5)
end
end
end

it doesn't error and it doesn't award Credits!
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
18 Jun 2014 09:14 AM
Is a defined above as a table?
Report Abuse
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
18 Jun 2014 09:15 AM
What comes before that bit of the script?
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:16 AM
After winneraward = 1

a = game:GetService("Players"):GetChildren()
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:20 AM
@ domorox17
I thing the answer is yes.
@ Zecrit
The setup of the game.
@ Drak0Master
Don't need that. GetService is only needed if the service is a hiden service or no already in the game.
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:24 AM
Also comes in handy when the name of the service is changed. All around more stable.

Besides that, a is not defined in your sample code, hence my input. As far I'm concerned, you do need it.
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:27 AM
Oh sorry didn't copy that over.
Here is the script with that:

winneraward = 1
a = game.Players:GetChildren()
for i=1, #a do
if a[i].TeamColor == BrickColor.new("Really blue") then
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value + winneraward
print(a[i].Name.." Has "..a[i].leaderstats.Credits.Value.." Credits")
store = game:GetService("DataStoreService"):GetDataStore("LeaderBoard")
local child= a[i].leaderstats:GetChildren()
for i=1, #child do
child[i].Value= store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
end
wait(5)
end
end
end
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:31 AM
Other than that, it seems you might be using the SetAsync() a bit ambiguously.

Try debugging. It might a nitpicky thing like this:

print(""..tostring(a[i].userId)..child[i].Name..","..child[i].Value.."")
child[i].Value= store:SetAsync(tostring(a[i].userId)..child[i].Name,child[i].Value)
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:34 AM
No the SetAsync() is alright it runs thu this snip of code and keeps going without any errors.

If I put a line of code at the bottom it would run it.

And I use Data Stores a lot I know what I am doing.
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:35 AM
The problem is that this line seems to be not running:
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value + winneraward
Report Abuse
SimIcy is not online. SimIcy
Joined: 29 Apr 2014
Total Posts: 95
18 Jun 2014 09:36 AM
for i=1, #a do
if a[i].TeamColor == BrickColor.new("Really blue") then
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value = +1
print(a[i].Name.." Has "..a[i].leaderstats.Credits.Value.." Credits")
store = game:GetService("DataStoreService"):GetDataStore("LeaderBoard")
local child= a[i].leaderstats:GetChildren()
for i=1, #child do
child[i].Value= store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
end
wait(5)
end
end
end
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:36 AM
Credits is a NumberValue/IntValue/etc?
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:39 AM
@ Drak Credits is an IntValue
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:39 AM
@SimIcy What did you change?
Report Abuse
SimIcy is not online. SimIcy
Joined: 29 Apr 2014
Total Posts: 95
18 Jun 2014 09:40 AM
I added a = and removed winneraward and put it after Value =
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:42 AM
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value = +1

Will error.
Report Abuse
SimIcy is not online. SimIcy
Joined: 29 Apr 2014
Total Posts: 95
18 Jun 2014 09:44 AM
Then try

for i=1, #a do
if a[i].TeamColor == BrickColor.new("Really blue") then
a[i].leaderstats.Credits.Value = +1
print(a[i].Name.." Has "..a[i].leaderstats.Credits.Value.." Credits")
store = game:GetService("DataStoreService"):GetDataStore("LeaderBoard")
local child= a[i].leaderstats:GetChildren()
for i=1, #child do
child[i].Value= store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
end
wait(5)
end
end
end


You had 2 leader stat credit.value's i don't see why you need them
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:47 AM
Because lets say you have the value "Apple = 1" and you want to add 1 to "Apple". You would have to have the value of "Apple" + 1. So to make "Apple" be "Apple + 1" you would have to do "Apple = Apple + 1"
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 09:48 AM
And changing the winneraward to 1 didn't help anything.
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 09:50 AM
Correct.

=+ is an incorrect syntax.
Report Abuse
yodaisme is not online. yodaisme
Joined: 20 Mar 2013
Total Posts: 282
18 Jun 2014 10:01 AM
Sorry it was my error this line:
child[i].Value = store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
Should have been:
store:SetAsync(a[i].userId..child[i].Name,child[i].Value)
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
18 Jun 2014 10:11 AM
Oh wow. How obvious! :-P
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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