So I have a placement system in my game and it works for the first wall but when I place more it duplicates and makes like 2X the amount can someone help me or tell me whats wrong thanks for reading!

Normal Script: local RP = game:GetService("ReplicatedStorage") local PlaceStructure = RP:WaitForChild("PlaceStructure") local Structures = game.ReplicatedStorage.Craftable_Items:WaitForChild("Structures")

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Plr = game.Players.LocalPlayer
local StrcFrame = script.Parent.ScrollingFrame
local char = Plr.Character or Plr.Character:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")

local mouse = Plr:GetMouse()

local yBuildingoffset = 5
local maxplacingdisc = 50
local rkeyispressed = false
local placingstruceture = false

for _, structrueButton in pairs(StrcFrame:GetChildren())do
	if(structrueButton:IsA("TextButton"))then
		structrueButton.MouseButton1Up:Connect(function()
			StrcFrame.Visible = false
			
			local yOrientation = 0
			local goodtoplace = false
			local placedstucture
			
			if(placingstruceture == false)then
				placingstruceture = true
				
				local clientstructure = Structures:WaitForChild(structrueButton.Name):Clone()
				clientstructure.BrickColor = BrickColor.new("Really blue")
				clientstructure.Material = "Neon"
				clientstructure.CanCollide = false
				clientstructure.Parent = game.Workspace
				
				local startingCFRAME = CFrame.new(0,-2,-15)
				clientstructure.CFrame = HRP.CFrame:ToWorldSpace(startingCFRAME)
				
				RunService.RenderStepped:Connect(function()
					local mouseray = mouse.UnitRay
					local castRay = Ray.new(mouseray.Origin,mouseray.Direction * 1000)
					local ignorelist = {clientstructure, char}
					local hit,position = workspace:FindPartOnRayWithIgnoreList(castRay, ignorelist)
					
					if(hit and (HRP.Position - clientstructure.Position).Magnitude < maxplacingdisc) then
						goodtoplace = true
						clientstructure.BrickColor = BrickColor.new("Really blue")
					else
						goodtoplace = false
						clientstructure.BrickColor = BrickColor.new("Crimson")
					end
					
					local newAnglesCFRAME = CFrame.Angles(0, math.rad(yOrientation), 0)
					local newCFRAME = CFrame.new(position.X,position.Y + yBuildingoffset, position.Z)
					clientstructure.CFrame = newCFRAME * newAnglesCFRAME
				end)
				UIS.InputBegan:Connect(function(input)
					if(input.KeyCode == Enum.KeyCode.R)then
						rkeyispressed = true
						
						local rotationspeed = 5
						while rkeyispressed do
							wait()
							if(placingstruceture == true)then
								yOrientation = yOrientation + rotationspeed
							end
						end
					end
				end)
				
				UIS.InputEnded:Connect(function(input)
					if(input.KeyCode == Enum.KeyCode.R)then
						rkeyispressed = false
					end
				end)
				
				UIS.InputBegan:Connect(function(input)
					if(input.UserInputType == Enum.UserInputType.MouseButton1)then
						if(placingstruceture == true)then
							if(goodtoplace == true)then
								local StructureCFRAME = clientstructure.CFrame
								placedstucture = PlaceStructure:InvokeServer(clientstructure.Name, StructureCFRAME)
								
								if(placedstucture == true)then
									placingstruceture = false
									clientstructure:Destroy()
									StrcFrame.Visible = true
								end
							end
						end
					end
				end)
			end
		end)
	end
end

Local Script: local RP = game:GetService("ReplicatedStorage") local PlaceStructure = RP:WaitForChild("PlaceStructure") local Structures = RP.Craftable_Items:WaitForChild("Structures")

PlaceStructure.OnServerInvoke = (function(player, StructureName, StructureCFrame)
	wait(1)
	local crafted
	local realstructure = Structures:FindFirstChild(StructureName):Clone()
	
	if(realstructure)then
		realstructure.CFrame = StructureCFrame
		realstructure.Parent = game.Workspace
		crafted = true
	else
		crafted = false
	end
	
	return crafted
end)