How can I put first person arms into the players viewport?

How can I put first person arms into the players viewport?
Note: My arms also have a gun in there hands

Alright, this may be a bit long so follow along.

STEP ONE: Get your viewmodel

I got mine by making it myself a while ago, but you can just use the toolbox.

Now, we must set it up.

Add an animation controller into your viewmodel.
view

(You can add an animator inside of the animation controller, keep in mind, if you want to play animations on it, you will have to do AnimationController.Animator:LoadAnimation(anim))

Now, add a main part. I will call this HumanoidRootPart. (Make sure to anchor it)
view
Inside of the humanoidrootpart, Make two Motor6Ds. One for the left arm, one for the right.

armsWeld

Connect the motor6Ds to the respective part, then adjust the offset of the motor6d to your liking.

Then, add the viewmodel into ReplicatedStorage. You can put it anywhere, just remember to use the correct hierarchy.
rs

Then, add a RemoteFunction into replicated storage. This will ensure every person that joins will get a viewmodel.

STEP 2: Scripting (yay)
Add a local script in StarterPlayerScripts or StarterCharacterScripts.
sps
Inside of the script, write this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteFunction = replicatedStorage.RemoteFunction -- pathway to function

local viewmodel = remoteFunction:InvokeServer() -- invoke server yields code until server returns whatever you need, so you dont have to use :WaitForChild() and stuff
viewmodel.Parent = workspace -- you can add it into a folder if you'd like

game:GetService("RunService").RenderStepped:Connect(function()
	viewmodel.HumanoidRootPart.CFrame = workspace.CurrentCamera.CFrame
end) 

Great. We have finished the Local Script. now, we must add a ServerScript in ServerScriptService.
sss
Inside the script, we will write our viewmodel function.

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteFunction = replicatedStorage.RemoteFunction -- pathway to function

local function returnViewmodelClone()
	local viewmodel = replicatedStorage.Viewmodel:Clone()
	viewmodel.Parent = replicatedStorage -- If you dont set the parent, the client wont get the correct code
	return viewmodel
end

remoteFunction.OnServerInvoke = returnViewmodelClone -- Connecting function


And there you have it! It is that easy!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.