I'm attempting to create a rotatable turret mounted on the back of a truck. The parts of the truck (including the gun) are welded to the base. If I set the lookvector of the gun to the mouse.hit, it moves the whole truck. However, when I set the lookvector of the C0 of the weld used for the gun, the gun doesn't move at all.
Does anyone have a way to move the turret in all three axes?
the current code looks something like this:
doesn't move the gun at all:
local pos = vector3.new(0,0,0) local gun = game.Workspace.Gun local weldc0 = gun.Weld.C0 while true do weldc0 = CFrame.new(weldc0.CFrame.p,pos) wait(0.1) end
moves whole truck, including gun:
local pos = vector3.new(0,0,0) local gun = game.Workspace.Gun local weldc0 = gun.Weld.C0 while true do gun.CFrame = CFrame.new(gun.CFrame.p,pos) wait(0.1) end
Am I doing this wrong or is there a better way?
I know it's a little late and there are definitely a few new ways to change up the welds, add attachments, and solve this simpler, but I currently have ran into the same issues with welds.
If you've figured it out, please let me know.
And to answer the question, the weld object was designed to be static and not dynamic. The C0 and C1 are independent cframes that unanimously build the specific cframe that keeps it in place. The reason why changing the gun.CFrame worked was because the weld(s) held everything in place and the CFrame changed just one part but because everything else is statically held together, it all moved.