|
| 31 May 2014 06:35 AM |
I'm using datastore, I'm getting the error "Unable to cast value to function". I don't use datastore very much so forgive me for my inevitable silly mistake.
PointSave = game:GetService("DataStoreService"):GetDataStore("Points")
for i = 1, #pplz do PointSave:UpdateAsync(pplz[i], pplz[i].Points.Value) end |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 06:36 AM |
I would just love to know what 'pplz' is.
|
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:57 AM |
pplz is the Players in Players.
local pplz = game.Players:GetChildren() |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 06:58 AM |
PointSave = game:GetService("DataStoreService"):GetDataStore("Points")
for _, Object in pairs(game:GetService("Players"):GetPlayers()) do PointSave:UpdateAsync(Object.userId, Object.Points.Value) end
key is the user's userid. |
|
|
| Report Abuse |
|
|
| |
|
uyoyalt
|
  |
| Joined: 16 Apr 2013 |
| Total Posts: 2860 |
|
|
| 31 May 2014 07:12 AM |
| Trio, is there a way to GetAsync of a certain player even the player isnt in the game? |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:16 AM |
| I'm still getting the same error. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 07:31 AM |
@uyoyalt Use the userId.
@op Use setasync or read this: http://wiki.roblox.com/index.php?title=Data_store#UpdateAsync.28key.2C_function.28oldValue.29_return_newValue.3B_end.29 |
|
|
| Report Abuse |
|
|
uyoyalt
|
  |
| Joined: 16 Apr 2013 |
| Total Posts: 2860 |
|
|
| 31 May 2014 07:33 AM |
@Trio
It returns not the value though (When I print), I have tried it. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 07:34 AM |
| Then you haven't saved the data correctly/with the correct key. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:50 AM |
I have read it and I see no reason for it not to work. Does the user have to have a current save before it can update it?
PointSave = game:GetService("DataStoreService"):GetDataStore("Points")
while true do wait(1) for _, Object in pairs(game:GetService("Players"):GetPlayers()) do
if Object:FindFirstChild("Points") then PointSave:UpdateAsync(Object.userId, Object.Points.Value) else print("No points found") end end
end |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 08:06 AM |
| I don't think you have read it because you're using it wrong. Use SetAsync. |
|
|
| Report Abuse |
|
|
| |
|
uyoyalt
|
  |
| Joined: 16 Apr 2013 |
| Total Posts: 2860 |
|
|
| 31 May 2014 08:22 AM |
@Trio
No it returns like a table |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 31 May 2014 08:33 AM |
what returns 'like a table'?
I have experience with datastores, trust me. |
|
|
| Report Abuse |
|
|