My goal for this script is to have it rotate a mesh that is welded to a bunch of other meshes without rotating all of the meshes/parts that are welded to it.
So, there is a plow that is welded to the car automatically by A-Chassis. When my current code runs, it rotates the entire car instead of just the plow mesh.
Current Code:
local blade = script.Parent.Blade
local rotationAmount = 20
local rotationSpeed = 1
function rotateBlade()
local currentRotation = 0
while currentRotation < rotationAmount do
blade.CFrame = blade.CFrame * CFrame.Angles(0, math.rad(rotationSpeed), 0)
currentRotation = currentRotation + rotationSpeed
wait()
end
end
rotateBlade()
Video demonstrating what happens currently:
Please let me know how to do this or if it is even possible.
I believe if you want to rotate a welded part you have to manipulate either the C0 or C1 properties of the weld rather than changing the CFrame of the part directly, which means you have to use a standard weld rather than a weld constraint
A post with a similar issue to yours has been posted before and has a solution set so perhaps that could help you out
local blade = script.Parent.Blade
local rotationAmount = 20
local rotationSpeed = 1
local weld = blade.ImportantWeld
function rotateBlade()
local currentRotation = 0
while currentRotation < rotationAmount do
weld.C0 = weld.Part0.CFrame:ToObjectSpace(CFrame.new(weld.Part1.Position + weld.C1.Position) * CFrame.Angles(0, math.rad(rotationSpeed), 0))
currentRotation = currentRotation + rotationSpeed
wait()
end
end
rotateBlade()
Thanks for the help, I was able to get it working with this code after changing around some things.
local blade = script.Parent.Blade
local rotationAmount = 20
local rotationSpeed = 1
local weld = blade.ImportantWeld
function rotateBlade()
local currentRotation = 0
while currentRotation < rotationAmount do
weld.C0 = weld.C0 * CFrame.Angles(math.rad(rotationSpeed), 0, 0)
currentRotation = currentRotation + rotationSpeed
wait()
end
end
rotateBlade()