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

How do I share the value of a variable in a script to a local script?

Asked by 5 years ago

I know it's poorly worded, but I have this value that counts how many players are in the game on a regular script. I need this value to be assigned to the most recent player joined. (ex. CHOCO73887 joins, so the player count variable is 1, and it needs to send this information to his local script so that the game knows he's player 1.)

How would I go about doing this? How do I send the value from a script to a local script?

3 answers

Log in to vote
0
Answered by 5 years ago

Just put an IntValue in ReplicatedStorage and assign its value with the variable's value, then from your localscript you will just need to get the value of the IntValue.

Ad
Log in to vote
0
Answered by 5 years ago

just create an IntValue in replicate ReplicatedStorage and do it:

--Normal
wait(5)
local value = 1
print("NormalScript:",value)
game.ReplicatedStorage.IntValue.Value = value
--Local
game.ReplicatedStorage.IntValue.Changed:Connect(function()
    print("LocalScript:",game.ReplicatedStorage.IntValue.Value)
end)
Log in to vote
0
Answered by 5 years ago

Use a remote function

Answer this question