Need help with Motor6D animating

  1. What do you want to achieve?
    A star shaped target. The star itself is spinning, while the targets on the ends spin with it. After hitting a target - it falls.

  2. What is the issue?
    I have a problem with scripting motor6D C0 or C1 for the target to rotate around it’s own PivotPoint.

  3. What solutions have you tried so far?
    Just rotating part’s CFrame won’t work as it is connected with Motor6D and will rotate the middle part as well. Therefor I either have to come up with different solution or rethink how the rotation with mid part works.

How it connects:
Mid part(that spins) connected with Motor6D to each target mesh(that should fall).

Code I have as of now, but it doesn’t work as intended

local char = script.Parent
local hum = char:FindFirstChildOfClass("Humanoid")
local hitBox = char:FindFirstChild("HitBox")

local part = hitBox.WeldConstraint.Part1
local motor6d = part:WaitForChild("Motor6D") 

local initialC0 = motor6d.C0
local totalRotationAngle = 0 

function rotatePinkPart(motor, degrees, axis : Vector3)
	totalRotationAngle = totalRotationAngle + math.rad(degrees)
	local localRotation = CFrame.Angles(0, 0, totalRotationAngle) 
	motor.C0 = localRotation * initialC0
end

hum:GetPropertyChangedSignal("Health"):Connect(function()
	print("Damaged")
	rotatePinkPart(motor6d, -90, Vector3.new(0, 0, 1))
end)

How it rotates:

I have came up with a decision to just do this after target is hit:

  • Delete Weld(Changed from Motor6D to Weld, yea)
  • Rotate the Target around it’s PivotPoint
  • Weld it back

I guess it shouldn’t cause any big troubles but will save my braincells

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.