Clones that appear on the client's pov are transfered into the next object that is placed in the workspace

local replicatedstorage = game.ReplicatedStorage
local PFunction = game.ReplicatedStorage:WaitForChild("PFunction")
local structures = game.ReplicatedStorage:WaitForChild("Structures")
local userinputservice = game:GetService("UserInputService")

local runservice = game:GetService("RunService")
local player = game.Players.LocalPlayer
local structureFrame = script.Parent.Frame
local char = player.Character or player.Character:Wait()
local humanoidrootpart = char:WaitForChild("HumanoidRootPart")

local mouse = player:GetMouse()


local yBuildingOffset = 5
local rKeyispressed = false
local placingstructure = false

for i, v in pairs(structureFrame:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Up:Connect(function()
			structureFrame.Visible = false
			local goodtoplace = false
            local placedstructure
			local yOrientation = 0
			
			if placingstructure == false then
				placingstructure = true
				
				local clientstructure = structures:FindFirstChild(v.Name):Clone()
				clientstructure.CanCollide = false
				clientstructure.Parent = game.Workspace	
                
				local StartingCframe = CFrame.new(0, -2, -15)
				clientstructure.CFrame = humanoidrootpart.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 hit.Shape == Enum.PartType.Block then
					
						goodtoplace = true
					else
						goodtoplace = false
					end


					local NewAngleCframe = CFrame.Angles(0, math.rad(yOrientation), 0)
					local NewCframe = CFrame.new(position.X, position.Y + yBuildingOffset, position.Z)
					clientstructure.CFrame = NewCframe * NewAngleCframe
				end)
				userinputservice.InputBegan:Connect(function(input)
					if input.KeyCode == Enum.KeyCode.R  then
						rKeyispressed = true

						local rotationspeed = 5
						while rKeyispressed do
							task.wait()
							if placingstructure == true then
								yOrientation = yOrientation	+ rotationspeed
							end
						end
					end
				end)
				userinputservice.InputEnded:Connect(function(input)
					if input.KeyCode == Enum.KeyCode.R  then
						rKeyispressed = false
					end
				end)
				userinputservice.InputBegan:Connect(function(input)
					if input.UserInputType == Enum.UserInputType.MouseButton1 then
						if placingstructure == true  then
							if goodtoplace == true then
								local StructureCframe = clientstructure.CFrame
								placedstructure = PFunction:InvokeServer(clientstructure.Name, StructureCframe)

								if placedstructure == true then
									placingstructure = false 
									clientstructure:Destroy()
									structureFrame.Visible = true
								end
							end
						end
					end
				end)
			end
		end)
	end
end

So, I was trying to make a placement system (code is copied from the dev king’s tutorial) and came upon a lot of errors. Fortunately, I was able to debug all the ones that output errors, but now I am left with this bug that clones the part in replicated storage to show in the client’s pov but then also clones to the next object selected after that. i.e, if I click on a sand block and place it, it will then display the previous sand block ontop of the selected object.

local clientstructure = structures:FindFirstChild(v.Name):Clone()
				clientstructure.CanCollide = false
				clientstructure.Parent = game.Workspace