Changing Text For One Label

Hi, I wanted to make a part where you type text in a gui, then goes on the part(Achieved)

The problem is when I type in the title, it changes for the description to(same for the game title)

I did try changing the scripts up a bit, but nothing is working.

Sorry if I’m being confusing.

Script under SurfaceGui:

--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)

remoteEvent.OnServerEvent:Connect(function(player, message)
	remoteEvent:FireAllClients(game:GetService("Chat"):FilterStringForBroadcast(message, player)) --Send our message back to all clients.
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)

Script Under Frame:

--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.GameName.Text)
	game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
	EditButtonUi.Visible = true
end)

remoteEvent.OnClientEvent:Connect(function(message)
	workspace.Part.SurfaceGui.GameNameLabel.Text = message
end)

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)

Thank You.

It is because you are changing both the description and the text when firing the remote event.
Here:

and here,

To avoid this, you would want to tell the client which one it should change,

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

game.Players.PlayerAdded:Connect(function(player)
	script.Parent.Parent.ClickDetector.MouseClick:Connect(function(player)
		player.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = true
	end)
end)

remoteEvent.OnServerEvent:Connect(function(player, type_, message)
	remoteEvent:FireAllClients(type_, 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("name", script.Parent.GameName.Text)
	remoteEvent:FireServer("description", script.Parent.Description.Text)
	game.Players.LocalPlayer.PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
	EditButtonUi.Visible = true
end)

remoteEvent.OnClientEvent:Connect(function(type_, message)
	if type_ == "name" then
		workspace.Part.SurfaceGui.GameNameLabel.Text = message
	elseif type_ == "description" then
		workspace.Part.SurfaceGui.GameDescriptionLabel.Text = message
	end
end)
1 Like