This tutorial is outdated, instead follow this one Making a simple fps framework. Part 1
This is not good as like those gun fps kits on the toolbox
Its night for me right now of making this post so this is going be in parts.
Step 1: Getting the viewmodel in to our camera
This is most easy part of making a lazy fps shooter.
So lets start of getting our viewmodel:
Heres a file for this:
coolViewModel.rbxm (12.1 KB)
Also you may notice theres animations for this viewmodel that I made. You can use thoses.
Ok once you got that done make a folder in ReplicatedStorage called Viewmodels and put the model you imported into the Viewmodels folder.
Now make a module in ReplicatedStorage called FPS.
It should look like this:
Go in your FPS module and type this:
local module = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local Viewmodels = ReplicatedStorage:WaitForChild("Viewmodels")
local viewModel : Model
function module:EquipGun(Name)
viewModel = Viewmodels:WaitForChild(Name):Clone()
viewModel.Parent = workspace.CurrentCamera
end
RS.RenderStepped:Connect(function()
if viewModel then
viewModel:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame)
end
end)
return module
Now make a localscript in StarterPlayerScripts and then type this :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FPS = require(ReplicatedStorage:WaitForChild("FPS"))
FPS:EquipGun("ViewmodelAim")
And there you go!
Step 2: Animations
Now since theres already animations in the viewmodel go publish the animations.
Now add this to your FPS module:
function module:animate(type)
if type == "Idle" then
if viewModel then
viewModel.AnimationController:LoadAnimation(viewModel.AnimationController.Idle):Play()
end
end
end
Now your module should look like this :
local module = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local Viewmodels = ReplicatedStorage:WaitForChild("Viewmodels")
local viewModel : Model
function module:animate(type)
if type == "Idle" then
if viewModel then
viewModel.AnimationController:LoadAnimation(viewModel.AnimationController.Idle):Play()
end
end
end
function module:EquipGun(Name)
viewModel = Viewmodels:WaitForChild(Name):Clone()
viewModel.Parent = workspace.CurrentCamera
module:animate("Idle")
end
RS.RenderStepped:Connect(function()
if viewModel then
viewModel:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame)
end
end)
return module
Also change the animation id to this:
And you got this!
END!
Now in the next part we will be doing extra animations and shooting!