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 instance to int?

Previous Thread :: Next Thread 
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
07 Nov 2014 11:29 PM
script.Link.OnServerEvent:connect(function(plr)
return (PointsService:GetGamePointBalance(plr))
end)

--This is server sided.

--It should return Player Points balance to a local script which fires the function with
pts==script.Parent["PP Manager"].Link:FireServer(game.Players.LocalPlayer.userId)


--What did I do wrong?

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Nov 2014 11:30 PM
Well for one, the first argument for remoteevents/functions are the player themselves, so you don't need to have the blah.userId part.

And for 2, you should be using a remotefunction for this since you are returning something.
Report Abuse
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
07 Nov 2014 11:34 PM
GetGamePointBalance
Returns the total number of points a player has in the current game. Works with server scripts ONLY.
Parameters

int userId - The userId of the player.

--Roblox Wiki.

Can you give me an example of returning back the value? Sounds like a lot of work just to return a int value.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Nov 2014 11:35 PM
return (PointsService:GetGamePointBalance(plr.userId))
pts=script.Parent["PP Manager"].Link:FireServer();

Like I said, use a remote function also.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Nov 2014 11:37 PM
script.Link.OnServerInvoke = function(plr)
return PointsService:GetGamePointBalance(plr.userId);
end;


From the client:
--It should return Player Points balance to a local script which fires the function with
pts=script.Parent["PP Manager"].Link:InvokeServer();
Report Abuse
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
07 Nov 2014 11:37 PM
I wanted to avoid that. Darn. I'll just put everything in a server script then to avoid complexity over transferring little info.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Nov 2014 11:38 PM
Why are you avoiding RemoteFunctions
Report Abuse
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
07 Nov 2014 11:41 PM
I guess I needed a remote function not an event. Thanks. That simplified everything.
Report Abuse
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
07 Nov 2014 11:42 PM
I didn't read up on remote functions. I only used remote events. Now that I know, remote functions could serve me better :3
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