I switched the script to StarterPlayerScripts and it still didn’t work, I’m still not seeing the viewmodel.
local function onUpdate(dt)
camera.CFrame = viewModel.Head.CFrame
end
Switch the position of your variables in your method like I did above ^
Ok so the issue is that your camera is still following the default spot. What I would do is weld the viewport frame onto the players body, and then make the Camera.CFrame follow it.
Okay, so I should weld the viewmodel arms to the players body and do this?:
local function onUpdate(dt)
camera.CFrame = viewModel.Head.CFrame
end
Yes something like that. I wrote some quick code to help you maybe understand it a bit better below:
local camera = game.Workspace.CurrentCamera;
local humanoid = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid");
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local function onUpdate(dt)
camera.CFrame = character.Head.CFrame
end
game:GetService("RunService").RenderStepped:Connect(onUpdate);
What i’m doing is just setting the cameras position to the players head. (But in your case you will need to first weld the viewModel onto the player, then do what I did above with the viewModel.Head position. It’s essentially the same thing)
Parent your viewmodel to the camera(or anywhere you want I guess). You are cloning it but not parenting it anywhere in the workspace so it never shows itself.
Yeah, still doesn’t work, not sure if I’m welding it correctly
local weld = Instance.new("WeldConstraint")
weld.Part0 = character.Head
weld.Part1 = viewModel.Head
weld.Parent = character.Head
Okay, I will attempt that and I’ll respond with the results.
Unfortunately, it still doesn’t work.
It’s possible you aren’t seeing your VIewmodel is due to it’s rotation. I’ve had this issue before, to essentially fix it, I’d use:
-- // This should flip the viewmodel 180 degrees. You might also need to apply it on the third component.
-- // For example, CFrame.Angles(0,math.pi,math.pi) but try the first method below :D
-- // You could alternatively use CFrame.Angles(0,math.rad(180),0) or something like that, but you'd
-- // have to do some experimentation with that.
viewModel.Head.CFrame = camera.CFrame * CFrame.Angles(0,math.pi, 0)
If it’s not the rotation then I wouldn’t really know just experiment with this for now and I’m sure it will eventually work
I believe the problem is not with the rotation, I’m not seeing the viewmodel at all in the game. I pasted your code into my script, and it still doesn’t work, but thanks for the help .
Is your viewmodel invisible? Also have you welded it onto the player correctly?
Actually, you forgot to parent the viewmodel
This isn’t a good way because when he clones the viewmodel it remains in the start position so the camera will be moved to the model and he needs the contrary. I suggest to parent the viewmodel to the player’s character and then set it’s CFrame to the player’s character HumanoidRootPart CFrame
Do you know where I can parent it to?
You can parent it to either workspace.CurrentCamera or workspace. Try workspace.CurrentCamera
I replied with what he should do here too.
Don’t worry mate, he legit forgot to parent it in the first place.
Yeah, I tried welding, but it doesn’t seem to work.
local weld = Instance.new("WeldConstraint")
weld.Part0 = character.Head
weld.Part1 = viewModel.Head
weld.Parent = character.Head