Motor 6D not working properly during single frame

Let’s get straight to the point. Here is my code:

local motor = Instance.new('Motor6D')
motor.Name = self.viewmodel.ArmRoot.Name
motor.Part0 = self.viewmodel.ArmRoot
motor.Part1 = self.viewmodel.Weapon.Grip
motor.C0 = self.offset
motor.Parent = self.viewmodel.Weapon.Grip

which should work totally fine.

However look what happens after motor gets parented:


As you can see it shows at 0,0,0 position (relative to its parent obviously) and after one frame it changes its position to the correct one.

(Motor 6D is used to connect weapon model to the viewmodel.)

Any help is really appreciated as this is annoying as hell.

maybe try cframing the model to the correct position before making it visible
the process might look cleaners like:

  1. model’s parent is nil/replicatedFirst
  2. cframe model and all of its parts to their respective places relative to character
  3. setup the motor6D
  4. parent the model to wherever in workspace you leave them

Unfortunately no luck. Code I used:

local clone = self.currentWeapon.Weapon:Clone()
local motor = Instance.new('Motor6D')

clone.PrimaryPart.CFrame = self.viewmodel.ArmRoot.CFrame

motor.Name = self.viewmodel.ArmRoot.Name
motor.Part0 = self.viewmodel.ArmRoot
motor.Part1 = clone.Grip
motor.C0 = self.offset
motor.Parent = clone.Grip

clone.Parent = self.viewmodel

Oh gosh I finally figured it out. Everything was caused by single task.wait() inside module responsible for animations that I forgot to remove after debugging.

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