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

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

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

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.

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)

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