Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this welding script working?

Asked by 9 years ago

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."

0
I legit have no idea what you're trying to do. Could you explain.. what, and why, this is? Goulstem 8144 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You never defined "mouse"

Ad

Answer this question