I have a label tool, which creates text on an object. It works fine, but when you use it on multiple objects, it changes the previous objects text to your recent entered text. Anyone know why this is happening? Here is my local script:

wait()
active = false
local m1
local m2

local toolGui = script.Parent.LabelTool
local play = script.Parent.Parent.Parent
local box

function click(targ)
	if targ ~= nil then
	if targ.Locked == false then
		if not targ:FindFirstChild("TextGUI") then
				
		game.ReplicatedStorage.Visiblegui:FireServer()
		game.ReplicatedStorage.Creategui:FireServer(targ)
		game.ReplicatedStorage.Fireplayer.OnClientEvent:Connect(function(plr)

repeat wait() until 	toolGui.toolGUI.TextButton.MouseButton1Click:Connect(function()

	game.ReplicatedStorage.ServerF:FireServer(toolGui.toolGUI.textBox.Text, targ)
toolGui.toolGUI.Visible = false
end)
end)
game.ReplicatedStorage.playerf.OnClientEvent:Connect(function(plr)
	toolGui.toolGUI.Visible = true
end)
			
return
		else
		game.ReplicatedStorage.Visiblegui:FireServer()
		end
	end
	end
end

function hover(targ)
	if not box then
		box = Instance.new("SelectionBox")
		box.Color = BrickColor.new("Deep blue")
		box.Transparency = 0.4
		box.Parent = script.Parent
	end
	if targ ~= nil then
	if targ.Locked == false then
		box.Adornee = targ
		box.Parent = game.Workspace
	else
		box.Adornee = nil
		box.Parent = script.Parent
	end
	end
end

script.Parent.Selected:connect(function(m)
	active = true
	toolGui.Parent = play.PlayerGui
	m1 = play:GetMouse().Button1Down:connect(function()
		 click(play:GetMouse().Target) 
		end)
	m2 = play:GetMouse().Move:connect(function() hover(play:GetMouse().Target) end)
end)

script.Parent.Deselected:connect(function()
	active = false
	toolGui.Parent = script.Parent
	m1:disconnect()
	m2:disconnect()
end)


Server side script:


game.ReplicatedStorage.Creategui.OnServerEvent:Connect(function(plr, targ)
	
local gui = game.ServerStorage.TextGUI:Clone()
			gui.label.Text = "text"

			gui.Parent = targ
			game.ReplicatedStorage.Fireplayer:FireClient(plr, targ)

end)
	game.ReplicatedStorage.ServerF.OnServerEvent:Connect(function(plr, text, targ)
local object = targ
print(targ)
object.TextGUI.label.Text = text

end)
game.ReplicatedStorage.Visiblegui.OnServerEvent:Connect(function(plr)
	game.ReplicatedStorage.playerf:FireClient(plr)
		
end)
	

There are no errors or anything. Any help is appreciated!

2 comments

1

"repeat wait() until toolGui.toolGUI.TextButton.MouseButton1Click:Connect(function()" the heck what do you think that does

0

It works man.