so i have a script that lets me make a road to grambys kinda building system. although for some reason when i take a part off and put it back on, it makes more and more welds.
i put it on the first time, 1 weld(good).
i put it on again, 2 welds
again, 4 welds
again, 8 welds…
idk whats going on, heres the part of the script responsible for handling this:
--Nodes
local Nodes = script.Parent.Nodes
local Tank = Nodes.Tank
local RBL = Nodes.RightBackLight
local LBL = Nodes.LeftBackLight
local Engine = Nodes.Engine
local Battery = Nodes.Battery
local FLL = Nodes.FrontLeftLight
local FRL = Nodes.FrontRightLight
--Other Values
local objselected = nil
local PlaceSender = game.ReplicatedStorage:WaitForChild("PlaceSender")
local PlaceReciver = game.ReplicatedStorage:WaitForChild("PlaceReciver")
--Node Sender
PlaceSender.Event:Connect(function(Param, Type)
print("Started")
if Param == "Ready" then
if Tank:FindFirstChild("Weld") then
print("Removing weld!")
Tank.Weld:Destroy()
end
Tank.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = Tank
Weld.Part0 = Tank
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To Tank!")
end)
if RBL:FindFirstChild("Weld") then
print("Removing weld!")
RBL.Weld:Destroy()
end
RBL.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = RBL
Weld.Part0 = RBL
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To RightBackLight!")
end)
if LBL:FindFirstChild("Weld") then
print("Removing weld!")
LBL.Weld:Destroy()
end
LBL.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = LBL
Weld.Part0 = LBL
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To LeftBackLight!")
end)
if Engine:FindFirstChild("Weld") then
print("Removing weld!")
Engine.Weld:Destroy()
end
Engine.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = Engine
Weld.Part0 = Engine
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To Engine!")
end)
if Battery:FindFirstChild("Weld") then
print("Removing weld!")
Battery.Weld:Destroy()
end
Battery.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = Battery
Weld.Part0 = Battery
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To Battery!")
end)
if FLL:FindFirstChild("Weld") then
print("Removing weld!")
FLL.Weld:Destroy()
end
FLL.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = FLL
Weld.Part0 = FLL
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To FrontLeftLight!")
end)
if FRL:FindFirstChild("Weld") then
print("Removing weld!")
FRL.Weld:Destroy()
end
FRL.ClickDetector.MouseClick:Connect(function(plr)
plr.ObjSelected.Value = false
local Weld = Instance.new("Weld")
Weld.Parent = FRL
Weld.Part0 = FRL
Weld.Part1 = Type.PlacementPart
print("Moved"..Type.Name.."To FrontRightLight!")
end)
end
end)
(please ignore my bad code, im not very good)
Thanks for any help!