Hello, I would like to transfer a global table to my local script. Is there any way?
(SERVER SCRIPT)
print(_G.tab[1]) --> player has got 5 points.
(LOCAL SCRIPT)
print(_G.tab[1]) --> nil
I tried to transfer the data via a StringValue, and Changed event, but it hardly works. (Bad timing)
Use RemoteEvents, they are extremely helpful in this situations.
LocalScript inside player's PlayerGui
event = game.ReplicatedStorage:WaitForChild("Stream") event.OnClientEvent:connect(function(msg) print(msg) end)
Script inside ServerScriptService
event = Instance.new("RemoteEvent", game.ReplicatedStorage) event.Name = "Stream" while wait(5) do event:FireAllClients("Player has got 5 points") end
You can also fire the event for only a client using FireClient(Player player, arguments)