
In this post we will be talking about creating our very own filtering enabled friendly first person shooter (FPS) game. * maincf -we merge the camera cframe with the offset and then set it as the viewmodels position.This guide was originally written for scriptinghelpers. If currentweapon then -we add this so the framework doesnt cry when there is no currentweapon add this above the setup() runs.RenderStepped:Connect(function() Now we will add the last lines for actually positioning the gun. Weaponmodule = require(gunmodules:WaitForChild(primary))Ĭurrentweapon = gunmodels:WaitForChild(primary):Clone() Lets get back to the framework we got some stuff to do. Settings.maincf = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0) -with this you will be able to edit the guns positionĮxciting right? We will finally slap the gun to your face. Create a module script inside modules and call it the same as the viewmodel.Great we now will add some gun settings inside a module. Setup(primary) -the weapon we set up is getting sent to the function function setup(weapon) -so the system know what weapon we set up Now we will add a function that will set up the gun to our face so we dont have to do any complex scripting, how genius. Local maincf = CFrame.new() -we will use this shortly Local secondary = "" -not yet in use (coming in a few tutorials) Local gunmodules = rs:WaitForChild("modules") Local gunmodels = rs:WaitForChild("models") Local runs = game:GetService("RunService") So basically we will have a function that will set up the gun to your face and basically make the system more flexible We will start by adding a loop to check if the game is loaded. Make a new local script inside starter player ➔ starter character scripts call it whatever you want.Now drop it in the models folder inside replicated storage and call the viewmodel the guns name. Lastly weld the handle to the humanoid root part.
