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

The tutorial also shows how to make hit detection with projectiles. Doing hit detection on server will be inaccurate because the delay of communicating with server which can be significant with the fact that the player has moved in those delays and can cause false negatives / positives.

@ATrashScripter

1 Like

Oh, I see why you use a remote event now. Sorry for that misunderstanding, It’s pretty weird for me when I see a local script fire a remote event to the server for damaging, :+1:

1 Like

Hey @EXM_0 can you are anybody send me an uncopylocked place that are working? I followed the steps but something just doesn’t work for me!

Seems really useful, one thing I want to see is how to make the arms be in place in the player’s hands? Like how it is other fps games (e.g. Phantom Forces, Arsenal, etc.), but if it’s already done in the tutorial, then excuse me as I was just blindly replying this lol.

Help, it’s spamming this error:
image

function module.update(ViewModel, dt, recSpring)
	ViewModel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame
	
	local updatedSpring = recSpring:Update(dt)
	
	ViewModel.HumanoidRootPart.CFrame *= CFrame.Angles(math.rad(updatedSpring.X)*2,0,0)
	game.Workspace.Camera.CFrame *= CFrame.Angles(math.rad(updatedSpring.X),0,0)
end
game:GetService("RunService").RenderStepped:Connect(function(dt)

MainModule.update(ViewModel, dt, recSpring)

end)
1 Like

You need to weld the Motor6Ds properly which I already explained how in the tutorial.

Hey, for some reason my swaySpring won’t work, here’s my update function:

function module.update(viewmodel, dt, RecoilSpring, BubbleSpring, SwayingSpring)
	viewmodel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame
	
	local Bubble = Vector3.new(GetBobbing(10),GetBobbing(5),GetBobbing(5))
	local MouseDelta = game:GetService("UserInputService"):GetMouseDelta()
	
	local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
	
	BubbleSpring:shove(Bubble / 10 * (Character:FindFirstChild("HumanoidRootPart").Velocity.Magnitude) / 10)
	
	local updatedRecoilSpring = RecoilSpring:update(dt)
	local UpdatedBobbleSpring = BubbleSpring:update(dt)
	local UpdatedSwaySpring = SwayingSpring:update(dt)
	
	viewmodel.HumanoidRootPart.CFrame = viewmodel.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(UpdatedBobbleSpring.Y, UpdatedBobbleSpring.X, 0))
	viewmodel.HumanoidRootPart.CFrame *= CFrame.new(UpdatedSwaySpring.X, UpdatedSwaySpring.Y, 0)
	
	viewmodel.HumanoidRootPart.CFrame *= CFrame.Angles(math.rad(updatedRecoilSpring.X) *2, 0, 0)
	game.Workspace.Camera.CFrame *= CFrame.Angles(math.rad(updatedRecoilSpring.X), math.rad(updatedRecoilSpring.Y), math.rad(updatedRecoilSpring.Z))
	
	
end

There’s no error btw, it’s just that I don’t notice I swing.

It looks like you didn’t show the sway spring.

Change :Update() to :update() on the spring

2 Likes

Is it oki if you give some more info about this? It seems to be causing errors for some people.

Thanks for the tutorial! I got the idea how people make gun viewmodel framework :). I made it semi too.

1 Like

One problem when I hit downwards it damages me.

1 Like

The bullet hit detection is probably detecting your leg, you need to add your character into the ignore list.

Well, thanking for helping me!

At least, you should edit the tutorial when you hit the leg thing so that players won’t complain lol.

3 Likes

Where is the error coming from? Like show in output

1 Like

Does anybody know how I could add a headshot multiplier?

local NormalDamage = 10
if Hit.Instance.Name == "Head" then
    damage:FireServer(Hit.Instance.Parent, NormalDamage * 4)
else
    damage:FireServer(Hit.Instance.Parent, NormalDamage)
end

Also, I suggest you do the hit detection on the server if you’re trying to make a serious FPS game, the way the tutorial does damage is very easily exploitable.

3 Likes

I know, just check the player is clicking the mouse at Head level.

Help, I’ve been trying your solution for gun swapping, but it’s had issues. Problem is, the guns will swap, but will stack the recoil every time a gun is swapped until being fired, and will give me this:
image

(game.StarterPlayer.StarterCharacterScripts.LocalHandler) The script with issues:

GiveGun.Event:Connect(function(GunModel)
	pcall(function()
		if Clickdet.Connected then
			Clickdet:Disconnect()
		end
		print("disconnected!")
	end)
	local AnimationsFolder = RepStore:WaitForChild(GunModel.."Animations")
	GunModel = RepStore:WaitForChild(GunModel):Clone()
	TrueModel = game.Workspace.Camera:FindFirstChild("Viewmodel")
	if TrueModel:FindFirstChildWhichIsA("Model") then
		TrueModel:FindFirstChildWhichIsA("Model"):Destroy() 
	end
	wait(.0001)
	MainModule.weldgun(GunModel)
	MainModule.animate(TrueModel, AnimationsFolder.Hold)
	print("e")
	print(GunModel.Name.." "..TrueModel.Name)
	TrueModel.Parent = game.Workspace.Camera
	MainModule.equip(TrueModel, GunModel)
	MainModule.animate(TrueModel, AnimationsFolder.Hold)
	local CanFire = true
	if GunModel.Name == "StarterPistol" then
		Delayy = 0.5
		Range = 50
	elseif GunModel.Name == "LaserRifle" then
		Delayy = 0.25
		Range = 100
	end

	Clickdet = game:GetService("RunService").RenderStepped:Connect(function(dt)
		mouse.Button1Down:Connect(function()
			if CanFire then
				CanFire = false
				recSpring:shove(Vector3.new(3, 0, 0))
				print(GunModel.Name)
				MainModule.cast(GunModel.Components.Barrel.Position, GunModel.Name, mouse.Hit.Position,Range)
				wait(Delayy)
				CanFire = true
			end
		end)
	end)
end)