Hi! I have a Script in wich i have a table
mytable = { [1] = "Element1", [2] = "Element2", [3] = "Element3" }
I want to pass it to my LocalScript in wich i have
print(mytable[1])
Is there any way to do it? Thanks in advance!
Yes, in fact with FilteringEnabled turned on (Which is very important), you kinda have to have exclusive communication between the client and the server and vice versa.
I present to you: RemoteEvents
RemoteEvents can have its event called from the server or client to have its parameters sent to the other end, you usually place RemoteEvents (and RemoteFunctions) in ReplicatedStorage (its like ServerStorage, but the clients get to peek in aswell)
Client side:
-- this is a localscript local Event = game.ReplicatedStorage.SendBeans -- the RemoteEvent in question local Beans = 0 -- how many beans we currently have Event.OnClientEvent(function(BeansToGive) Beans = Beans + BeansToGive end)
Server side: it should be noted that you have to specify which client you are communicating with as the first parameter
-- this is a server script local Event = game.ReplicatedStorage.SendBeans -- the RemoteEvent, yet again local Player = game.Players.fanofpixels local BeansStorage = 10 function GiveBeans() Event:FireClient(Player, BeansStorage) BeansStorage = 0 end GiveBeans() -- if you are trying to fire the event for ALL clients, then try this method instead: Event:FireAllClients(BeansStorage)
More information can be found here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events