Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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)

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. lomo0987 250 — 10y
0
An intValue hold Integers. I use StringValue because it holds Strings. FieryEvent 185 — 10y

1 answer

Log in to vote
1
Answered by
Destrings 406 Moderation Voter
10 years ago

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)

Ad

Answer this question