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 » Scripters
Home Search
 

Re: Using _G to store temporary player data?

Previous Thread :: Next Thread 
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:18 PM
What are the (dis)advantages of using _G to store player data like for example kills in _G rather than the traditional method of using value objects?
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Sep 2015 05:19 PM
the client won't be able to access the data
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Sep 2015 05:20 PM
value objects were made exactly for this purpose
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
07 Sep 2015 05:20 PM
Use modulescripts
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:22 PM
@instawin

The client could still access the data via remotes no?

@ByDefault

How is that going to work?
Report Abuse
MaliciousMammoth is not online. MaliciousMammoth
Joined: 25 Jan 2015
Total Posts: 7
07 Sep 2015 05:23 PM
Use value objects, stop trying to do it this way, this is awful.
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:25 PM
@MaliciousMammoth

It seems to me that it's more memory efficient and much less of a hassle to work with when you have a lot of fields
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Sep 2015 05:26 PM
"The client could still access the data via remotes no?"

well yeah, sure, you could use a remote function to return the value inside of _G.. but why are you trying to dodge this? invoking to the server would just cause more network traffic than necessary.
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
07 Sep 2015 05:27 PM
They're more memory efficient? Lol, you shouldn't concern yourself with a couple kilobytes of saved memory.
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:32 PM
@instawin

It seems like a cleaner and easier to work with solution to me.
I do not think it would increase network traffic by much at all since you could pipeline changing the data via a function that then fires a RemoteEvent for the client with the argument being the data entry changed and their new value.
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Sep 2015 05:35 PM
do what you want, i just see it as more hassle though
why go through all of that when value objects replicate to the client as well? you wouldn't even need to deal with remote events/remote functions
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
07 Sep 2015 05:37 PM
It will take at least 100 milliseconds to get the value on faster connections, and up to a second on slower connections, but okay, do what you want.
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:37 PM
But then every players data would be replicated to every other players client as well which would increase traffic significantly
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Sep 2015 05:37 PM
*you wouldn't even need to deal with remote events/remote functions (unless you want to invoke the server to change a value)

the client could access the value object and read from the value object's .Value property though
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:38 PM
@foreverpower

What is your point? It is not like the value replication would be any faster in that scenario
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
07 Sep 2015 05:38 PM
Well, when you want to get the value, do you request it, or does the server send the new value every time it updates?
Report Abuse
AgentVanBur is not online. AgentVanBur
Joined: 31 Dec 2013
Total Posts: 289
07 Sep 2015 05:42 PM
If you scroll up a bit you can see I have provided a solution to this particular issue which is using a RemoteEvent that fires upon the data
Report Abuse
DeveloperBlue is online. DeveloperBlue
Joined: 15 Apr 2009
Total Posts: 1344
07 Sep 2015 05:51 PM
Using value objects are you best option. If you use remote events and functions, you lose the .Changed event (Very useful for displaying the stats instantly) and have to depend on latency. ie someone get's a kill, they don't get the stat update until anywhere from less than a second to sometimes 2-3 seconds or more.

There are no advantages to using _G over using value objects. Other than it 'feels nicer' grabbing data directly from a table, it's more common and logical to use Value objects.

As someone said prior, Value Objects exist almost solely for these reasons.
Report Abuse
DeveloperBlue is online. DeveloperBlue
Joined: 15 Apr 2009
Total Posts: 1344
07 Sep 2015 05:54 PM
Using _G over Value Objects

Advantages:
'Feels nicer' grabbing from a table

Disadvantages:
No access to the .Changed event, you may need to keep looping to find out of a value has changed, or code a custom Changed event.
Clients need to use remote events and functions to grab and detect data, this can be slow due to latency.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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