Im not sure how to fix this error, pls help

Im trying to make a tool that places a part and welds it to the part it placed on.

I keep getting this error : “Expected BasePart got Player for WeldConstraint.Part0.”

Im not sure exactly what to do.

Heres the script for further detail:

local tool = script.Parent
local handle = tool.Handle
local furniture = tool:FindFirstChild("Furniture")
local Event = script.Parent.Place

function place(targetPart, position)
	
	if targetPart then
		-- Clone furniture into Workspace
		local newFurniture = furniture
		handle.Weld:Destroy()
		newFurniture.Anchored = false
		newFurniture.Parent = workspace
		--newFurniture.Position = position + Vector3.new(0, 1.75, 0)

		-- Weld it to the clicked part
		wait(1)
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = targetPart  -- The part clicked
		weld.Part1 = newFurniture  -- The placed furniture
		weld.Parent = newFurniture

		print("Furniture placed and welded!")
	end

	script.Parent:Destroy()
end

Event.OnServerEvent:Connect(place)

What is firing the remoteevent? I don’t see anything wrong with this

You need to add the first argument “player” to the function place(). Right now the player is being passed and bound to targetPart, which explains your error.

2 Likes

i forgot about that :pray: :sob:

like this?

function place(plr, targetPart, position)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.