Making a driveby feature, Arm movement isnt synced properly

So i want to make a diveby system that holds your arm up, loads an animation, leans you out and lets you free armed driveby, the only problem is the arm moves abit too far and unsynced from the camera

example:
I look to the front, arm to the right, i look to the right, arm to the cars back (too far to the right)

been modifying the values for a long time now lol

RightShoulder.C0 = CFnew(0.5, (yOffset - 0), 0) * CFAng(0, -asin(CameraDirection.x), -25) * CFAng(asin(CameraDirection.y), 0, 0)

yes i have synced it to the server and the script’s position is in starter char scripts, Right shoulder is rightupperarm:WaitForChild(“RightShoulder”) Its a Motor6D or whatever, the movement is synced with RunService.RenderStepped

CameraDirection:

local root = character:WaitForChild("HumanoidRootPart")
local CameraDirection = root.CFrame:toObjectSpace(camera.CFrame).lookVector

if you need any more from the code ask me right away

Screenshot:

No replies so far :confused:
If you guys need further info to help, tell me

Not exactly sure what you’re trying to do here, could you try explaining it to me like I’m a 3-year-old? :sweat_smile:

1 Like

Well ima try, glad you atleast are interested to help…

So you know what a driveby is right? Shooting out of a car

So the player sits in passenger seat, holds right click and the script makes your arm go to the side and up, its supposed to aim to the front when the player looks ti the front, and to the right when player looks to the rght, the problem is that it points to the right when the player is looking to the front, when looking tl the right the arm points to the back of the car

I’m not very good with cameras, but could you show me your entire script?

Theres no camera manipulation or anythin cameta related in the script that i did not name in the post but i can show you later
(Leave a like if you do need the entire script)
Everything else in the script is just requiring the gun, holding right click, the variables and head movement which works fine

Im not on pc rn thas why

1 Like

When you use Cframe.Angles you need to use math.rad for numbers like -25. You said that your arm is rotated wrong about 90 degrees you could either use pi/2 or math.rad(90) to change it 90 degrees.

1 Like

ima try that, i’ll tell ya right away if it worked!

where would i put those things even

this is what i currently got

RightShoulder.C0 = CFnew(0.5, yOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), math.rad(90), 0)

The good thing is now it looks to the right and front when i look to the right and front when i look to the front, but instead of also being able to aim to the back it can look to the left, i would like it to be able to be front, right and back and not left front and right, how can i change that or am i gonna need to create another animation for looking back drivebying, i’d do that regardless anyway sooo

(the left,front,right and back i talked about are from car perspective btw)

I’m a bit confused, maybe you could send a video? I think what your saying is its shifted over a bit. That might mean you need to play around with the numbers. Maybe try math.rad(135) or math.rad(180). I’m not 100% sure what you are saying though.

1 Like

Maybe this image could help!

How it is now
20210403_002456|690x388 !

What i want
20210403_002522|690x388

The images show the rotation limits btw

Oh okay I see it’s pointing out the front instead of the sides. I think what I said above applies. Although I think you just ned to rotate on a different axis maybe. Sorry I can’t test anything I don’t have my computer with me.

I can point to the right but the limits are wrong, i can point to the car’s left, front and right
But i want to be able to point to the cars’ front, right and back

with changing axis you mean for example z instead of x?

oh hey, thanks G!!
Changing the axis’s worked, this is what i got now, its only abit too deep i have to adjust the height but i can do that myself

RightShoulder.C0 = CFnew(0.5, yOffset, 0) * CFAng(0, -asin(CameraDirection.z), math.rad(0)) * CFAng(asin(CameraDirection.y), 0, 0)

No problem just remember when using CFrame.Angles to use math.rad to move it how you want it.

1 Like

to anyone else wondering, you have to replicate it to your server with an event, and add a Tween between the movements, its the RightUpperArm.RightShoulder’s C0 you have to replicate, or else it will only be local!!