FPS Viewmodel not working

I switched the script to StarterPlayerScripts and it still didn’t work, I’m still not seeing the viewmodel.

1 Like
local function onUpdate(dt)
	camera.CFrame = viewModel.Head.CFrame
end

Switch the position of your variables in your method like I did above ^

1 Like

I’m getting this, now:

1 Like

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.

1 Like

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
1 Like

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)

2 Likes

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.

1 Like

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
1 Like

Okay, I will attempt that and I’ll respond with the results.

1 Like

Unfortunately, it still doesn’t work.

1 Like

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 :sweat_smile: just experiment with this for now and I’m sure it will eventually work :smiley:

2 Likes

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 :grinning:.

Is your viewmodel invisible? Also have you welded it onto the player correctly?

1 Like

Actually, you forgot to parent the viewmodel :sweat_smile:

1 Like

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

2 Likes

Do you know where I can parent it to?

1 Like

You can parent it to either workspace.CurrentCamera or workspace. Try workspace.CurrentCamera

2 Likes

I replied with what he should do here too.

1 Like

Don’t worry mate, he legit forgot to parent it in the first place.

1 Like

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
1 Like