-
What do you want to achieve?
I want to make a gun system for one of my games. -
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. -
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.