FPS Tutorial [Part 2]

Hello everyone and this is my third fps tutorial and is the second part! I did it as I stated in my last tutorial that I will make a tutorial on advanced systems.

Disclaimer: I am new to FPS making so please point out any errors or mistakes and I will be using the basics of this video here .

In this part we will be covering on how to make the gun aim and add idle animations.

Lets begin!

1. Aiming
Now we will be making the gun aim, I will do it a bit simpler way of trying to guess the offset instead of making an aim part.

  • In the framework we will add a new CFrame variable called aimcf:
    image

  • Now make a bool and call it aiming:
    image

  • And last but not least inside the run function:

if aiming then
			--we will put something inside this shortly
		else
			--also soon
		end
--note put this under the set primary part cframe

Now finally we put in the script:

  • If aiming true:
aimcf = aimcf:lerp(weaponmodule.aimcf, 0.1) --the cframe offset and the speed
  • If aiming false:
aimcf = aimcf:lerp(CFrame.new(), 0.1) --resetting the cframe

Now inside the gun module add a setting called the something like aimcframe or something.

Settings.aimcf = CFrame.new(0,0,0) * CFrame.Angles(0,0,0) --the aim offset dont do anything yet

2. Key binding
In this part we will make the gun actually aim.
lets begin!!!11111

  • For aiming we dont need User Inpur Service since right mouse button can be accessed with mouse.
    Check if you have mouse variable if not:
local mouse = plr:GetMouse()

Now finally lets detect when right mouse button is pressed down:

mouse.Button2Down:Connect(function()
	-- our script will be here
end)

And when its released:

mouse.Button2Up:Connect(function()
    -- we will add our script here soon
end)

Now are you ready for the script?
Inside button down:

aiming = true

Inside button up:

aiming = false

3. Animations
In this part we will only do idle animation. I will try and explain this part as best as I can.

  • Inside the module create a setting called idleanim
Settings.idleanim = "rbxassetid://"

Now inside setup we will set it as the animation like this:

local idle = Instance.new("Animation", currentweapon)
idle.AnimationId = weaponmodule.idleanim
local idleanim = currentweapon:WaitForChild("Humanoid"):LoadAnimation(idle)
idleanim:Play()

Now make your animation, publish it and get the animation id.
I will leave all the animations in animsaves inside the viewmodel.

  • Insert the animation into the setting inside the module.

Test if it works!

4. The aiming offset
This will we a short part of the tutorial I will just explain a bit on how to guess it faster.

  • Tip 1
    CFrame.new(left-right, up-down, forward-backwards)
  • Tip 2
    Dont be scared to use values like:
    CFrame.new(0.112,0.505,-1.2) the more numbers you add after the dot the less bigger it will be
  • Tip 3
    Try eyeing it, look how one stud looks and dont be afraid to experiment.

5. Outro
Thank you for reading this I really appreciate it thank you for everyone who commented who reported errors and really big thanks to GamerRyan18 who taught me a lot about FPS.
Next time we will maybe doing gun sway? Maybe shooting? You will need to wait to find out!
Part 3: Working on it…
Part 1: FPS Tutorial [Part 1]

Thank you and see ya later!

P.S the place also got updated.

24 Likes

You should probably have some experience with the topic you are wanting to teach, at this point you might as well just link to the videos. This written tutorial lacks a lot of information, like how am I meant to structure the code? The tutorial should continue from where the previous one left off. The video you linked also has some questionable practices, like polling for the game to be loaded instead of waiting for it to be loaded and instantly executing any code. Not to mention that is completely unnecessary for non-ReplicatedFirst stuff.

8 Likes

In all of my tutorials I state that I am beginner and thats how I do things, you should take a look at black shibes tutorial and then say how do i stucture the code.(no offense black shibe), I also stated that thats my second ever attempt at tutorials also in the bottom there is the place file if you are confused on how i explain. In other words thanks for the “advice” and now go do something else than just say how bad begginers do things and actually read the whole thing.

5 Likes

Part 2!
Thank you. My first reply to a post on devforum was part 1. So this is making me more comfortable posting stuff on devforum.

1 Like

In the next Tutorial, make sure to add running animations, prone, melee [basically using the stock to hit players]

2 Likes

Sure! I might put that in a later tutorial since the next one is probably gonna be shooting and is gonna go offtrack from the youtube tutorials.

Part 3 out!

For some reason my idle animation is not playing.

local settings = {}
settings.maincf = CFrame.new(0, -.2, 0) * CFrame.Angles(-.2, 0, 0)
settings.aimcf = CFrame.new(0,0,0) * CFrame.Angles(0,0,0)
settings.idleanim = "rbxassetid://6468351252"
return settings

Could you tell me whats wrong with it? Thanks :slight_smile: .

Edit: Fixed

Love this! Very simple and fun to listen and read! :upside_down_face:

1 Like

What was the problem? I could improve on it in the next tutorial.

I fixed the problem, thanks though.