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: Unable to cast value to function (Datastore)

Previous Thread :: Next Thread 
opploGames is not online. opploGames
Joined: 16 Nov 2013
Total Posts: 8
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 is not online. 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
opploGames is not online. opploGames
Joined: 16 Nov 2013
Total Posts: 8
31 May 2014 06:57 AM
pplz is the Players in Players.

local pplz = game.Players:GetChildren()
Report Abuse
Trioxide is not online. 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
opploGames is not online. opploGames
Joined: 16 Nov 2013
Total Posts: 8
31 May 2014 07:03 AM
Makes sense. Thank you.
Report Abuse
uyoyalt is not online. 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
opploGames is not online. opploGames
Joined: 16 Nov 2013
Total Posts: 8
31 May 2014 07:16 AM
I'm still getting the same error.
Report Abuse
Trioxide is not online. 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 is not online. 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 is not online. 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
opploGames is not online. opploGames
Joined: 16 Nov 2013
Total Posts: 8
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 is not online. 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
TrainingToTroll is not online. TrainingToTroll
Joined: 27 Oct 2012
Total Posts: 1757
31 May 2014 08:21 AM
Your doing it wrong.
LOL.
Report Abuse
uyoyalt is not online. uyoyalt
Joined: 16 Apr 2013
Total Posts: 2860
31 May 2014 08:22 AM
@Trio

No it returns like a table
Report Abuse
Trioxide is not online. 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
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