I have a gun that creates a weld with an object on another object. It clones a part in Workspace, makes a weld, welds the cloned part and the mouse's target, and depending on which side the gun targets, the weld moves 0.4 studs from a side. The script is missing a mousebutton1down function of course, but this is just a segment from the script:
local hit = mouse.Hit local star = game.Workspace.star:clone() local surface = mouse.TargetSurface star.Parent = game.Workspace star.Name = "starclone" star.Anchored = false local weld = Instance.new("Weld") weld.Parent = star weld.Part0 = star weld.Part1 = t -- "t" is the mouse's target if surface == Enum.NormalId.Right then weld.C0 = CFrame.new(0.4, 0, 0) elseif surface == Enum.NormalId.Left then weld.C0 = CFrame.new(-0.4, 0, 0) elseif surface == Enum.NormalId.Front then weld.C0 = CFrame.new(0, 0, -0.4) elseif surface == Enum.NormalId.Back then weld.C0 = CFrame.new(0, 0, 0.4) elseif surface == Enum.NormalId.Top then weld.C0 = CFrame.new(0, 0.4, 0) elseif surface == Enum.NormalId.Bottom then weld.C0 = CFrame.new(0, -0.4, 0) end
The problem is that the script doesn't move the cloned part at all. Can anybody help me out?
EDIT: After some experimenting, I found that the script should work perfectly well, but it can't assign the weld's parent to "star." I tried putting it in another object in Workspace, which worked, so I have no idea why its parent can't be "star."