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)


1 comment

0

You should not be reposting questions. Update your previous question and remove this one or it will be moderated.