Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Global Tables [Script to local script]. Is there any way?

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)

2 comments

0

You might be able to do an IntValue inside the player... But as you said before.. It hardly works. I don't know if there is another way.

0

An intValue hold Integers. I use StringValue because it holds Strings.

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.