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)