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

How do you share a variable from a Script to Local Script?

Asked by 5 years ago

Simply put, I have a loop in my server script that counts intermission up and I want my local script that is in a textlabel to display 30 -intermission. I don't know how to share a variable from a script to a local script. How do I?

0
You would use a remote event to tell all players to start a count down in a local script . User#5423 17 — 5y
0
^ bruh, I was gonna say that greatneil80 2647 — 5y
0
Ok! I'll do that! Noonekirby 162 — 5y
0
Kingdom5's answer of remotes event. Noonekirby 162 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

You could make an Int Value inside the Script and set its value to 30, so while the server script counts intermission, value would go down by 1 every second or whatever time you have chosen to apply. The local script would find that value and change the GUI's text to the value's value. Here's a sample how it would look.

game:GetService("ServerScriptService").IntermissionServerScript.IntValue.Changed:Connect(function(value) -- Checks for ServerScriptService and finds the IntValue inside your Intermission server script. Every time the value changes

textlabel.Text = value -- The text gui changes into the IntValue's value.

end)
0
Intvalues are bad practices, exploiters can hax it if it is written 'horribly'. id go for remotes greatneil80 2647 — 5y
0
just use a remote event lol User#23365 30 — 5y
0
also the client or "LocalScript" cant access ServerScriptService since its only used for the server User#23365 30 — 5y
Ad

Answer this question