|
| 10 Feb 2015 11:31 AM |
I'm making a GUI that shows all the players in the game and I need a ModuleScript
-abs |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 11:33 AM |
If you don't know what a ModuleScript is, you don't need it.
It allows you to make modules and re-use code in multiple scripts and stuff. For example, some people have made interpolation modules, for interpolating things. eLunate made a time module, to get the current time in many measurements, and et cetera. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 11:34 AM |
I thought ModuleScripts transferred data from Scripts to LocalScripts? Or am I getting confused?
-abs |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 10 Feb 2015 11:35 AM |
I don't see why you need a module
Modules are used to return a value
Often a table of functions or a function
Example, if you put a moduleScript in ReplicatedStorage and put this inside the Module
local module = {}
function module.test() print("This is a test") end
function module.otherTest() print("This is another test") end
return module;
And in a script if you do
local blah = require(game.ReplicatedStorage.ModuleScript) blah.test() -->This is a test blah.otherTest() -->This is another test |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 11:35 AM |
| You're talking about Remote Events and Remote Functions. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 11:36 AM |
aha yes those! how do you use them? xd
-abs |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:09 PM |
@Jarod
Aww I was thinking of making a time module that does that xD. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:10 PM |
| But it doesn't seem available for me to take :P. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:26 PM |
I never published my Time module, but the source is on my c9 and should work directly pasted into a moduleScript.
On that note, you want to use RemoteEvents dude. Never ever use a RemoteFunction unless it is imperitive that you wait for a response. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:27 PM |
| eLunate, Can I question what I would have to use that WOULD need a response? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:32 PM |
Polling a client for if it is ready (Which should actually be sent straight from the client...) Waiting for a client to complete an action is the most likely reason. This includes the server requesting for the client to preload an asset. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:35 PM |
| Ahhh Okay, I'll be using that then for Preload |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:42 PM |
Basically, RemoteEvents will always be the best solution except for certain circumstances. They're a mimicry of the kind of 'reliable' RPCs you use in actual game development, and are much faster for most things. Only use a RemoteFunction if you need to wait for the client/server to complete the request |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:45 PM |
So, how to use them?
-abs's alt |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:49 PM |
Server: [void] RemoteEvent:FireServer(...) [Event]RemoteEvent.OnServerEvent >> (Player, ...)
Client: [void] RemoteEvent:FireClient(Player, ...) [Event]RemoteEvent:FireAllClients(...) [Event]RemoteEvent.OnClientEvent >> (...)
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:49 PM |
Trust me. I just woke up again so uh don't shoot...
[void] RemoteEvent:FireAllClients(...)* |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 12:55 PM |
Void just means a function that doesn't return anything.
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:57 PM |
ok, so...
how would i use remoteevents to uhh..
transfer a table with a full list of players in the game to a localscript so i can display it on my gui? |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 10 Feb 2015 12:58 PM |
| Why not just do game.Players:GetPlayers()? |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 12:59 PM |
Because in each little frame showing the player i'm doing it like this:
p[1] p[2]
etc |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Feb 2015 01:05 PM |
| Wait no that really doesn't make sense why aren't you using game.Players:GetPlayers() |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 01:08 PM |
wait
if i do
plrs = game.Players:GetPlayers()
can i do
plrs[1] and stuff |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2015 01:09 PM |
| also i need it to remove people that leave so watttttttt |
|
|
| Report Abuse |
|
|