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
|
  |
| Joined: 06 Mar 2012 |
| Total Posts: 1710 |
|
|
| 18 Jun 2014 09:14 AM |
| Is a defined above as a table? |
|
|
| Report Abuse |
|
|
Zecrit
|
  |
| Joined: 24 Jan 2013 |
| Total Posts: 2618 |
|
|
| 18 Jun 2014 09:15 AM |
| What comes before that bit of the script? |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2014 09:16 AM |
After winneraward = 1
a = game:GetService("Players"):GetChildren() |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 18 Jun 2014 09:36 AM |
| Credits is a NumberValue/IntValue/etc? |
|
|
| Report Abuse |
|
|
yodaisme
|
  |
| Joined: 20 Mar 2013 |
| Total Posts: 282 |
|
|
| 18 Jun 2014 09:39 AM |
| @ Drak Credits is an IntValue |
|
|
| Report Abuse |
|
|
yodaisme
|
  |
| Joined: 20 Mar 2013 |
| Total Posts: 282 |
|
|
| 18 Jun 2014 09:39 AM |
| @SimIcy What did you change? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 18 Jun 2014 09:42 AM |
a[i].leaderstats.Credits.Value = a[i].leaderstats.Credits.Value = +1
Will error. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 18 Jun 2014 09:50 AM |
Correct.
=+ is an incorrect syntax. |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|