Designing an FPS Framework: Beginner’s guide [PART 2]

Would be good for a part 3 on server side replication :grimacing: in regards to having it show other players holding guns

2 Likes

I feel like it’s not needed as it’s pretty simple into implementing it, you send the server the current gun you’re holding and the server will play an animation on your character accordingly.

As I said it’s not supposed to you give a polished framework but instead supposed to teach you the fundamentals.

May I ask what spring module you use?

i dont remember what one exactly as i got it years ago. im pretty sure the one from nevermore engine is good

alright thank you I’m gonna try it out see if it work

Dude, the Spring Module earns my respect. Thank for this delightful tutorial!

Will the player’s see you holding the gun? If not, how could I do that?

1 Like

Hello, I am having a problem. When I get to close to the dummy / target it doesn’t damage them. My scripts match line to line to yours. Any help would be great thanks.

edit: Sorry for very late reply.

Maybe this will resolve your issue?

1 Like

Thanks for the help I will try when I am able too.

1 Like

Great post, I just have a question on how would I go about switching guns from primary to secondary?

It didn’t work, do you have any other solutions?

Well you haven’t provided me any video to show this, so I can’t really tell you exactly on what you need to do

Hello! I’ve tried making the viewmodel compatabile with tools, however the recoil stacks everytime you equip the tool. Can you please help me? I’ll give ya the full script of the tool.

local tool = script.Parent
local Viewmodule = game.ReplicatedStorage.Viewmodel
local Camera = game.Workspace.Camera
local GrozaLocal = game.StarterPlayer.StarterPlayerScripts.Groza_Gun
local AnimationsFolder = game.ReplicatedStorage:WaitForChild("GrozaAnim")
local GunModel = game.ReplicatedStorage:WaitForChild("Groza")

local MainModule = require(game.ReplicatedStorage.MainModule)
local SpringModule = require(game.ReplicatedStorage.SpringModule)

local RecoilSpring = SpringModule.new()
local BobbleSpring = SpringModule.new()
local SwaySpring = SpringModule.new()



tool.Equipped:Connect(function(equipped)
	print("h")
	MainModule.weldgun(GunModel)
	game:GetService("RunService").RenderStepped:Connect(function(dt)
		MainModule.update(Viewmodule, dt, RecoilSpring, BobbleSpring, SwaySpring)
	end)
	MainModule.equip(Viewmodule, GunModel, AnimationsFolder.Hold)
	Viewmodule.Parent = game.Workspace.Camera
	GrozaLocal.Disabled = false
	
	local IsPlayerHoldingMouse 
	local CanFire = true
	local Delay = 0.1
	
	game:GetService("RunService").Heartbeat:Connect(function(dt)
		if IsPlayerHoldingMouse then
			if CanFire then
				CanFire = false


				RecoilSpring:shove(Vector3.new(3, math.random(-2, 2), 10))

				coroutine.wrap(function()

					for i, v in pairs(GunModel.GunComponents.Barrel:GetChildren()) do
						if v:IsA("ParticleEmitter") then
							v:Emit()
						end
					end

					local FireSound = GunModel.GunComponents.Sounds.Fire:Clone()

					FireSound.Parent = game.Workspace
					FireSound.Parent = nil
					FireSound:Destroy()
				end)()

				coroutine.wrap(function()

					wait(.2)

					RecoilSpring:shove(Vector3.new(-2.8, math.random(-1, 1), -10))
				end)()	

				MainModule.cast(GunModel, game.Players.LocalPlayer:GetMouse().Hit.Position, 60, Damage)

				wait(Delay)
				CanFire = true
			end
		end
	end)

	game:GetService("UserInputService").InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			IsPlayerHoldingMouse = true
		end
	end)

	game:GetService("UserInputService").InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			IsPlayerHoldingMouse = false
		end
	end)

end)

tool.Unequipped:Connect(function(unequipped)
	Viewmodule.Parent = game.ReplicatedStorage
	GrozaLocal.Disabled = true
end)

I also get this error, it is in the recoil module script so it may be the root cause of the problem.

can you send the whole stack? i cant find the exact line

Sure, I’ll get it to ya right now. And Apologizes for responding so late, I don’t check the DevForum all that often. Also, Damage stacks too. How can I fix that?

image

try adding recoil recovery and sway limit to the next part of the framework tutorial

Cant seem to find the exact line with the code you sent. Mind giving me code in line 86

When I jump up and down the bobbing doesn’t look right to me. It looks too much like when running is there any way to fix this?