Make Text Show For One Part

Hi, I’m making a game. One part of my game is to be able to edit you own part. I know the reason why it’s not working(firing at the same time with other part), but I just don’t know how to solve it. I tried the Devforum, the developer hub, Youtube, and many other things. I still don’t know what I need to do.

I have 4 different scripts.

-- Main1
local EditMessage1 = game.ReplicatedStorage.EditMessage1
local MainParts = game.Workspace.MainParts
local PlayerGui = game.Players.LocalPlayer.PlayerGui

local function labels()
	EditMessage1:FireServer("name1", script.Parent.Parent.GameName.Text)
	EditMessage1:FireServer("description1", script.Parent.Parent.Description.Text)
end

PlayerGui:WaitForChild("EditingUi").EditGui.DoneButton.MouseButton1Click:Connect(function()
	labels()
	PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
end)

EditMessage1.OnClientEvent:Connect(function(type1_, message)
	if type1_ == "name1" then
		MainParts.Main1.SurfaceGui.GameNameLabel.Text = message
	elseif type1_ == "description1" then
			MainParts.Main1.SurfaceGui.GameDescriptionLabel.Text = message
	end
end)

This script is supposed to change part one(main1) of the one you claim(You edit text)

-- Main2
local EditMessage2 = game.ReplicatedStorage.EditMessage2
local PlayerGui = game.Players.LocalPlayer.PlayerGui
local MainParts = game.Workspace.MainParts

local function labels() 
	EditMessage2:FireServer("name2", script.Parent.Parent.GameName.Text)
	EditMessage2:FireServer("description2", script.Parent.Parent.Description.Text)
end

PlayerGui:WaitForChild("EditingUi").EditGui.DoneButton.MouseButton1Click:Connect(function()
	labels()
	PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
end)

EditMessage2.OnClientEvent:Connect(function(type2_, message)
	if type2_ == "name2" then
		MainParts.Main2.SurfaceGui.GameNameLabel.Text = message
	elseif type2_ == "description2" then
		MainParts.Main2.SurfaceGui.GameDescriptionLabel.Text = message
	end
end)

Same as part one but different part.

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

EditMessage1.OnServerEvent:Connect(function(player, type1_, message)
	EditMessage1:FireAllClients(type1_, game:GetService("Chat"):FilterStringForBroadcast(message, player)) --Send our message back to all clients.
end)

(This is a script for part1, but it is the same just with different remote event and type2_)

I would appreciate help, because this is supposed to be the main thing of the game which I cant figure out!

Also I have another problem that helps with my game: Click To Own Part Using Object Value

1 Like

Do you think you could elaborate on what isn’t working?

So when I edit the part, I need the text to display on only my part. When I click “Done” it goes on the other part too which I cant solve.

image
robloxapp-20210831-1955311.wmv (1.1 MB)

Aight first off, you’ve over complicated things, only 2 scripts should be used really to do this, one local and one server.
Second, there are massive security issues with your remotes, allows any exploiter to change any label they want to whatever they want.
Third, I’m confused what the loop is for here:

for i, v in pairs(table) do
	if type1_ == "name1" then
		MainParts.Main1.SurfaceGui.GameNameLabel.Text = message
	elseif type1_ == "description1" then
			MainParts.Main1.SurfaceGui.GameDescriptionLabel.Text = message
		end
	end

In all honesty, you should probably scrap your current system and try to figure out a more efficient way of doing it as continuing it will only cause more problems for you down the line. Sorry if I came across harsh but I’m only trying to give you the truth.
I also only see one remote event, I don’t know if its an old screenshot but if its what you have, I don’t know how you’re not erroring.

If you are going to continue using this method, I’d recommend removing the OnClientEvent and making it on the server as it’s not going to make much of a difference and it’s better if these types of things are on the server anyways.

To fix your current script, you’re going to need to run a check to get the part

PlayerGui:WaitForChild("EditingUi").EditGui.DoneButton.MouseButton1Click:Connect(function()
   if partClicked.Owner == game.Players.LocalPlayer then -- hypothetical way of doing it
	labels()
	PlayerGui:WaitForChild("EditingUi").EditGui.Visible = false
   end
end)

^ The above isn’t going to work, as you will need an Owner value or something, however if you are trying to make it so all players can do it, instead replace the Owner value to the gui, so if you click on the part, you set the value to the gui and then run the checks. The gui has no way of knowing of which to fire, main1 or main2 in short.

for i, v in pairs(table) do
if type1_ == “name1” then
MainParts.Main1.SurfaceGui.GameNameLabel.Text = message
elseif type1_ == “description1” then
MainParts.Main1.SurfaceGui.GameDescriptionLabel.Text = message
end
end

It was testing, I forgot to delete it!