How Do I change Text For Server?

Hi! I want to make a part with text you can edit(achieved), but it changing to the whole sever.

When I tested it with 2 players, one player can only see there text, not the other players.

I tried making it so instead of a local script, I would put it in a normal script which didn’t work.

I would like to know what I need to change or what I half to do. Thank you!

Code In Script:

game.Players.PlayerAdded:Connect(function(player)
	local message = game.Chat:FilterStringForBroadcast(script.Parent.GameNameLabel.Text, player)
	script.Parent.Parent.ClickDetector.MouseClick:Connect(function(player)
		player.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = true
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	local message = game.Chat:FilterStringForBroadcast(script.Parent.GameDescriptionLabel.Text, player)
	script.Parent.Parent.ClickDetector.MouseClick:Connect(function(player)
		player.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = true
	end)
end)

Code in Local Script:

local EditButtonUi = game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditButton

script.Parent.DoneButton.MouseButton1Click:Connect(function()
	local message = game.Chat:FilterStringForBroadcast(script.Parent.GameName.Text, game.Players.LocalPlayer)
	workspace.Part.SurfaceGui.GameNameLabel.Text = message
	game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
	EditButtonUi.Visible = true
end)

script.Parent.DoneButton.MouseButton1Click:Connect(function()
	local message = game.Chat:FilterStringForBroadcast(script.Parent.Description.Text, game.Players.LocalPlayer)
	workspace.Part.SurfaceGui.GameDescriptionLabel.Text = message
	game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
	EditButtonUi.Visible = true
end)

Code For Edit Button:

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local EditButtonUi = player.PlayerGui:WaitForChild("EditingUi").EditButton
local EditGui = player.PlayerGui:WaitForChild("EditingUi").EditGui

EditButtonUi.MouseButton1Click:Connect(function()
	EditGui.Visible = true
	EditButtonUi.Visible = false
end)

Sorry if it’s so much to read!

You need to fire your message to the server with a RemoteEvent, have the server filter the message, and then have the server :FireAllClients(filteredMessage) and have the clients display the message that was filtered.

--Server
local remoteEvent = game:GetService("ReplicatedStorage").EditMessage

game.Players.PlayerAdded:Connect(function(player)
	local message = game.Chat:FilterStringForBroadcast(script.Parent.GameNameLabel.Text, player)
	script.Parent.Parent.ClickDetector.MouseClick:Connect(function(player)
		player.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = true
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	local message = game.Chat:FilterStringForBroadcast(script.Parent.GameDescriptionLabel.Text, player)
	script.Parent.Parent.ClickDetector.MouseClick:Connect(function(player)
		player.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = true
	end)
end)

remoteEvent.OnServerEvent:Connect(function(player, message)
  remoteEvent:FireAllClients(game:GetService("Chat"):FilterStringForBroadcast(message, player)) --Send our message back to all clients.
end
--LocalScript
local remoteEvent = game:GetService("ReplicatedStorage").EditMessage

local EditButtonUi = game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditButton

script.Parent.DoneButton.MouseButton1Click:Connect(function()
	remoteEvent:FireServer(script.Parent.Description.Text)
	game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
	EditButtonUi.Visible = true
end)

remoteEvent.OnClientEvent:Connect(function(message)
	workspace.Part.SurfaceGui.GameDescriptionLabel.Text = message
end)
--Edit button
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local EditButtonUi = player.PlayerGui:WaitForChild("EditingUi").EditButton
local EditGui = player.PlayerGui:WaitForChild("EditingUi").EditGui

EditButtonUi.MouseButton1Click:Connect(function()
	EditGui.Visible = true
	EditButtonUi.Visible = false
end)

Since client changes are only seen on the client, On the client you need to get the text and fire it through a remote event to the server. The server picks it up and updates the text.

Where do I put the remote event?

I edited my answer above to provide some code.