Motor6D C1 Position and Orientation is different when set by a script

  1. What do you want to achieve?
    I want to make a gun system for one of my games.

  2. What is the issue?
    I am trying to make a motor6d to keep a weapon in place and make the C1 offset move the gun in place, where the right hand is, as well as orient it properly.

  3. What solutions have you tried so far?

  • I’ve set the C1 Manually, which worked and gave me the results I wanted, but it won’t work with a script.
  • I’ve searched on the developer forum for solutions, I’ve seen people with similar problems but their solutions didn’t work for me.
  • I’ve tried other ways of setting position and rotation (none of them worked)

Most parts of the scripts are cut out as they likely have nothing to do with the issue, as these are the only lines that have anything to do with Motor6D

Gun system local module script, in replicated storage:

	local Motor6D = Instance.new("Motor6D")
		Motor6D.Parent = _viewModel:WaitForChild("RightArm")
		Motor6D.Part0 = _viewModel:WaitForChild("RightArm")
		Motor6D.Part1 = viewModelGun.PrimaryPart
		Motor6D.C1 = _config.ViewModelOffset

Configuration script, local script in the gun model.

self.ViewModelOffset = CFrame.new(Vector3.new(-2.75, 0, -0.65)) * CFrame.Angles(math.rad(-90), math.rad(-90), 0)

What the script should do:

What it is doing: (There is a part of the gun sticking out in the lower right corner)

The difference between these images is the image that is correct, showing what the script should do, I just set C1 values to nothing, and then set the values to what they were prior.

Any help is appreciated, thank you.

2 Likes

The second image shows a different Orientation configuration. Are you sure the config has the right Orientation described? It looks to me as if it’s defined as 0, -90, 90 as opposed to the correct -90, -90, 0.

I tried setting the motor6D to -90, -90, 0, with the command

game.Workspace.Camera.ViewModel.RightArm.Motor6D.C1 = CFrame.new(Vector3.new(-2.75, 0, -0.65)) * CFrame.Angles(math.rad(-90), math.rad(-90), 0

although It still set its self to “0, -90, 90”, so now I believe that its a issue with how I’m setting the C1, would you know what the issue is with how im setting it?

I don’t know how I oversaw the value actually being 0, -90, 90 when set before, that is my bad.

1 Like

Apparently this had to do with something else in the script, however I have zero clue as to what, Otherwise it may have been because the place was saved to a file and not uploaded to Roblox? - I heard people had some weird issues with saved to file places.

Anyways, I remade the gun system in a game uploaded to Roblox, as I accidentally deleted the place file while removing OneDrive from my PC.

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