Hi, I have a system for setting scoreboards to what I type in a screengui for a live game show, but I don’t know how to make it update for the other players using remote events.
The script I currently use is this:
local box = script.Parent -- the TextBox
local secondBox = game.Workspace.Podium1.money.SurfaceGui.TextBox --- the second one where ever it is
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEventTest")
local function onTyped() -- callback
secondBox.Text = box.Text
end
box:GetPropertyChangedSignal("Text"):Connect(onTyped) -- pass callback to listener
Before I start, I suggest changing the TextBox in the SurfaceGui to a TextLabel to prevent other users from altering the Text on their side. I made this change in the scripts below.
In this case, it’d be preferable to use a Remote Event.
You will want to edit the TextLabel (in workspace) from the Script, so I removed that variable for this LocalScript:
local Box = script.Parent
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEventTest")
local function onTyped() -- Callback
RemoveEvent:FireServer(Box.Text) -- Send the Text property of Box to the server
end
box:GetPropertyChangedSignal("Text"):Connect(onTyped) -- Pass Callback to Listener
In the Server Script, we will retrieve what was sent from the Client and set the Text of the TextLabel:
local SecondBox = game.Workspace.Podium1.money.SurfaceGui.TextLabel -- Used to be a TextBox, now a TextLabel
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEventTest")
RemoteEvent.OnServerEvent:Connect(function(Player, Text)
if Player.Name == 'putYourNameHere' then -- Set putYourNameHere to your name, this is for security to make sure other users can't change the scoreboard.
SecondBox.Text = Text -- Sets the Text of SecondBox on the server so that all users will see the change
end
end)
Edit: I see that ROBLOX says that Text Filtering should be used when the developer does not have control over the content. So even though it wouldn’t be bad to include it, If you are in control it looks like it’s okay.