Still have questions? Join our Discord server and get real time help.
Log in to vote

Why does this make the part go into the distance instead of where I specified it?

Asked by 3 years ago

This script basically makes a barrel of a gun(for a tank) to point in the target's position(which is mouse.Hit.p). However, instead of locking onto the tank and pointing where it should, it just disappears. Help?

function move(target)
    if script.Parent.Parent:findFirstChild("Barrel") then
    local mp = barrel
    local dir = (target - mp.Position).unit
    local pos = mp.Position + (dir*1)
    if engine:FindFirstChild("WeldBarrel") then
        local wb = engine.WeldBarrel
        wb.C0 =, pos + dir) -- this is supposed to make the barrel point towards the mouse, but it just teleports off into the distance.

Answer this question