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: Get the data of this table from another script

Previous Thread :: Next Thread 
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
27 Nov 2017 06:51 PM
PlayerData = {}

game.Players.PlayerAdded:Connect(function(Player)
---
table.insert(PlayerData, Player.UserId)
PlayerData[Player.UserId] = {Cash = 400}
---
end)

This is a script that basically assigns each player a cash value with a data table.
Any possible ways to get the data of said user from another script?
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
27 Nov 2017 06:54 PM
could use _G or module script in this case i guess
Report Abuse
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
27 Nov 2017 06:58 PM
'could use _G or module script in this case i guess'

I feel like _G is hacky.

How would I use ModuleScripts?
Report Abuse
iiNemo is online. iiNemo
Joined: 22 Jul 2013
Total Posts: 2380
27 Nov 2017 07:00 PM
Bindable Events/Functions


Fish Are Friends, Not Food
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
27 Nov 2017 07:02 PM
_G has it's pros and cons but using something like bindables for this would be hacky
Report Abuse
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
27 Nov 2017 07:04 PM
Give me some pointer on how to use ModuleScripts with this, they seem efficient for this purpose
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
27 Nov 2017 07:06 PM
could make a mini api for this thing i guess like: local api = {} api.Data = {} function #################### ############# = val end function api.GetData(key) return api.Data[key] or default i guess xd end return api maybe idk
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
27 Nov 2017 07:07 PM
pVfhqxjn pbin
Report Abuse
ViciousSilence is not online. ViciousSilence
Joined: 02 Jun 2013
Total Posts: 912
27 Nov 2017 07:24 PM
A module script returns a value.

What can that value be? Anything.

You get the returned data in the module by doing:
local data = require(ModuleScipt)--Data becomes the returned value
Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
27 Nov 2017 07:28 PM
@Lae I'd say _G has the major downside of no ability to limit access (as far as I'm aware at least) where bindables can use getters and setters to limit direct access to the values held
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