Hey,
I’m working on this gun system but when I aim up or down the camera doesn’t move along with the gun, how do I fix this?
You will have to re-adjust the arm pivot point according to your current camera rotation as your arms rotate around a pivot point located in the middle of your torso
How’d I do that? _____________
Your arms need to rotate around the camera
if the black box is your camera, and the blue line represents your gun, your arms should look like they are attached to your camera to make sure that the red dots line up.
No yes I understand what he meant, I was just wondering how would I write the code or where should I start.
CFrames ain’t my thing really
A solution would be to set the viewmodels primary part cframe to the player’s head. Then trial and error the offset to make it look like its rotating around your torso.
game:GetService("RunService"):Connect(function()
Viewmodel:PivotTo(Character.Head.CFrame * OffsetCF)
end)
The Better Solution
You’re trying to use a global viewmodel for both the server and client. Don’t do this, please make them separate. Have one local viewmodel for the client and another for the server to replicate. It looks like you already have the code for the server viewmodel, just write one for the client.
Example
local viewmodel = game:GetService("ReplicatedStorage").VM:Clone()
local runservice = game:GetService("RunService")
--Set viewmodel parent to camera
viewmodel.Parent = workspace.CurrentCamera
runservice.RenderStepped:Connect(function(dt)
--pivot viewmodel around camera
viewmodel:PivotTo(workspace.CurrentCamera.CFrame * offsets)
end)
I forgot to mention but this is not a viewmodel.
It’s the player’s arms moving up and down
That’s the exact problem. It’s updating the player’s actual arms. Client viewmodels are better and have less lag and more reliability.
Then is there a possible way to make it so the animation that is played on the character’s animator is also played on the viewmodel’s animator? So I wouldn’t need to animate the viewmodel and the tool a lot
It is possible. You could just make one set of client viewmodels and reuse them on the server. The server would just weld them to the player model. Then you can use remote events to update the server so it can play animations and other stuff.
Ill give it a try _____________