FPS Viewmodel not working

I’ve parented it to game.Workspace.CurrentCamera

Result:

1 Like

Does it at least move around with your camera, if not, then something else must be wrong OR you still have your weld still inserted in there.

1 Like

I suggest to parent the viewmodel to the player’s character and then set it’s CFrame to the player’s character HumanoidRootPart CFrame every RenderStepped…

2 Likes

It doesn’t move, I also removed the weld.

1 Like

That’s not what he’s attempting to achieve, he’s trying to make an FPS viewmodel, not a 3rd Person one. Parenting to CurrentCamera and changing CFrames then will suffice.

1 Like

Ok but FPS = FIRST PERSON shooter so he should set the first person and problem solved

1 Like

Still doesn’t work…

Quick question. Does your Viewmodel have a PrimaryPart set? If not, try setting one, then, I recommend welding everything in the model to that PrimaryPart AND THEN, CFraming the Viewmodel.PrimaryPart in the RenderStepped update.

That’s not the problem, even if I did First Person for the camera, it doesn’t fix anything.

Okay, I’m going to try to make a PrimaryPart.

1 Like

There’s a flaw in what you’re trying to get him to achieve, if you parent it to the Character, and it sets to First Person Mode, then his whole character goes invisible, that includes all descendants of the character.

That is, unless you make your own custom camera and set it’s CFrame accordingly to the character, but even then, that posts many more issues.

1 Like

Maybe try taking it one step at a time. None of this code will work if your viewModel is not correctly parented and welded to the player correctly FIRST. Once you get that working, it will be a lot easier.

1 Like

Can you explain how I would make a PrimaryPart?

1 Like

On your model called “Viewmodel” you simply press the Property which says “PrimaryPart”, then click any part in the Viewmodel, preferably the Head and boom, you got yourself a PrimaryPart.

For FPS, I’m not meant to be putting it on the character, it’s meant to only just be attached to the camera. I’m following this tutorial by EgoMoose: The First Person Element Of A First Person Shooter

And now I just weld viewModel.Head to the Right and Left Arm, and then doing viewModel:SetPrimaryPartCFrame(onUpdate)?

No, you weld Right and LeftArm to the HEAD, then you can update the CFrame also by doing this:

Viewmodel.PrimaryPart.CFrame = --// blah blah

As you mentioned, you can also do it like this:

 Viewmodel:SetPrimaryPartCFrame(--[[blahblah]])
1 Like

It’s still laying on the ground. Also, this is my new code:

local camera = game.Workspace.CurrentCamera;
local character = game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid");

local viewModel = game.ReplicatedStorage:WaitForChild("viewModel"):Clone();
viewModel.Parent = character
viewModel.Head.CFrame = camera.CFrame * CFrame.Angles(0,math.pi, 0)

local rightArm = viewModel:WaitForChild("Right Arm")
local leftArm = viewModel:WaitForChild("Left Arm")

local weld = Instance.new("WeldConstraint")
weld.Part0 = leftArm
weld.Part1 = viewModel.Head
weld.Parent = leftArm

local weld2 = Instance.new("WeldConstraint")
weld2.Part0 = rightArm
weld2.Part1 = viewModel.Head
weld2.Parent = rightArm

local function onDied()
	viewModel.Parent = nil;
end

local function onUpdate(dt)
	viewModel:SetPrimaryCFrame(camera.CFrame)
end

humanoid.Died:Connect(onDied);
game:GetService("RunService").RenderStepped:Connect(onUpdate);
2 Likes

Now try also adding the rotation I showed.

2 Likes