yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 02:25 PM |
game.Players.PlayerAdded:connect(function(player) datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:GetAsync(key) if key == nil then datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 return newval end) end end)
I have yet to find my problem :c. |
|
|
| Report Abuse |
|
|
| |
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 02:43 PM |
game.Players.PlayerAdded:connect(function(player) datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 return newval end) end) |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 02:45 PM |
| still not working :c, i even tried it in play mode. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2014 03:01 PM |
| How do you know it is not working? |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 03:04 PM |
its supposed to update the value "Points" in the players leaderstats(Model)..
players -player1 --'leaderstats' ---'Points'
but I dont think i did it right did I ? |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2014 03:04 PM |
game.Players.PlayerAdded:connect(function(player) local l = Instance.new("Model", player) l.Name = "leaderstats" local p = Instance.new("IntValue", l) p.Name = "Points" datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 return newval p.Value = newval end) end)
Would it work? |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 03:07 PM |
| I already made the leaderboard script, should I incorporate that into the same script though just to try? |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 03:12 PM |
game.Players.PlayerAdded:connect(function(player) local l = Instance.new("Model", player) l.Name = "leaderstats" local p = Instance.new("IntValue", l) p.Name = "Points" datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 return newval p.Value = newval end) end)
16:08:48.024 - Workspace.Script:14: 'end' expected (to close 'function' at line 10) near 'p'
Also, i think it has to do with the line after return because whenever I removed 'p.Value' it doesnt error |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
| |
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
| |
|
|
| 03 Apr 2014 04:44 PM |
| That script should work... |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 05:12 PM |
it keeps saying that error i posted..
|
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 05:22 PM |
maybe I didn't make myself clear
basically this script is to award 50 points to the newly entered player, EVERYTIME.
So if someone joins in, he will get 50 points. If that same person joins again, he gets another 50 points and so on.. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2014 05:24 PM |
| Try adding an end. I don't see why there should be one. But the error says to... |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 03 Apr 2014 05:34 PM |
game.Players.PlayerAdded:connect(function(player) local l = Instance.new("Model", player) l.Name = "leaderstats" local p = Instance.new("IntValue", l) p.Name = "Points" datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 p.Value = newval return newval end) end)
I used this and it worked but only once and it doesn't work again.
game.Players.PlayerAdded:connect(function(player) local l = Instance.new("Model", player) l.Name = "leaderstats" local p = Instance.new("IntValue", l) p.Name = "Points" datastore = game:GetService("DataStoreService"):GetDataStore("Points") local key = "user_" .. player.userId datastore:UpdateAsync(key, function(oldVal) local newval = oldval or 0 newval = newval + 50 return newval end) p.Value = newval end)
This doesnt work at all.
Adding an extra end doesn't work either. Im getting annoyed :/.
|
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
| |
|