Designing an FPS Framework: Beginner's guide

I did remove that line


Same thing happens in 1st person, just it’s harder to see.

I made arms invisible so you can see easier

1 Like

Does it do the same thing with the groza model?

When it was welded to the spawn location (don’t ask) it worked fine (with the groza model) but when I removed the weld from the spawn (don’t ask x2) the y position was messed up. I think the problem is either the custom character, or the code has some wrong positioning.

If you want a video, I can provide.

1 Like

The only advice I could give right now is to either try and make the FPS framework the original way (no custom chars) directly from the tutorial then move on to custom chars. (or maybe it’s because it’s 2AM and I’m just really tired and I can’t notice obvious mistakes lol)

Same thing happened, also were you using R15, or R6? Also if you are tired and need to go to bed, it’s fine just sleep.

Well it didn’t matter if it was R15 or R6 because we aren’t using the roblox character rigs. Also I didn’t do this in the tutorial but try cloning the gunmodel and also the viewmodel.

1 Like

What do you mean by “cloning the view model and gunmodel”? Also sorry for late reply, I was busy with other stuff.

I got the bullet to stay at the center of your screen instead of the barrel, but it follows the player so it’s possible to use it. But on the other hand, if I aim down, the bullet go down, if I look up, the bullet goes down, I don’t know why but I’ll work on it.

Idk what I did but my gun is so far away from the camera!

local MainModule = {}

function MainModule.update(viewmodel, dt)
	viewmodel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame

function MainModule.WeldGun(gunModel)
	local Main = gunModel.GunComponents.Handle
	for i,v in ipairs(gunModel:GetDescendants()) do
		if v:IsA("BasePart") and v ~= Main then
			local newMotor ="Motor6D")
			newMotor.Name = v.Name
			newMotor.Part0 = Main
			newMotor.Part1 = v
			newMotor.C0 = newMotor.Part0.CFrame:inverse() * newMotor.Part1.CFrame
			newMotor.Parent = Main

function MainModule.Equip(gunModel, viewModel)
	local gunHandle = gunModel.GunComponents.Handle
	local HRP_Motor6D = viewModel:WaitForChild("HumanoidRootPart").Handle
	gunModel.Parent = viewModel
	HRP_Motor6D.Parent = gunHandle

return MainModule


local GunModel = game.ReplicatedStorage:WaitForChild("Groza")
local ViewModel = game.ReplicatedStorage:WaitForChild("Viewmodel")

local MainModule = require(game.ReplicatedStorage.MainModule)

ViewModel.Parent = workspace.Camera

	MainModule.update(ViewModel, dt)

MainModule.Equip(GunModel, ViewModel)

Do you have a video showing this?

1 Like

When I made an fps prototype instead of creating a new Motor6D when welding the gun, I already had one inside of the part that was not attached to anything so I could just set the gun to the attachment. Is my way more performant?

The reason I weld the gun inside the script is because when you need to do adjustments on the gun (example: adjusting sight or barrel placement) and if the Motor6D is already occupied, it will be destroyed but putting an empty Motor6D and assigning it later is also fine.

Okay, I see. Thanks for clarifying.

For some reason, the weld doesn’t work for me. It spawns the gun really far away from the arms. Here is the MainModule scripts

function Module.Weld(Gun)
	local Main = Gun.Main.Handle
	for i,v in pairs(Gun:GetDescendants()) do
		if v:IsA("BasePart") and v ~= Main then
			local NewMotor ="Motor6D")
			NewMotor.Name = v.Name
			NewMotor.Part0 = Main
			NewMotor.Part1 = v
			NewMotor.C0 = NewMotor.Part0.CFrame:inverse() * NewMotor.Part1.CFrame
			NewMotor.Parent = Main

function Module.Equip(Viewmodel, Gun)
	local GunHandle = Gun.Main.Handle
	local HRP6D = Viewmodel:WaitForChild("HumanoidRootPart").Handle
	Gun.Parent = Viewmodel
	HRP6D.Part1 = GunHandle

Do you have any footage showing this?

Here is what it looks like in game:

Here’s what it looks like in the workspace:image

Alright, I think I know the problem but just to confirm can you send the .update() function?

function Module.ViewmodelUpdate(Viewmodel, DT)

Viewmodel.HumanoidRootPart.CFrame = workspace.Camera.CFrame


Alright so try these:

Try and make sure every thing is unanchored. Make sure the gun’s parts and all of the viewmodel’s limb are unanchored (except the HumanoidRootPart)

If that doesn’t work, while ingame try go to you explorer and make sure all of your gun’s Motor6Ds are connected probably
All gun body parts are connected to handle
Handle is connected to HRP's Motor6D Handle


Okay, so I think I did something wrong because the handle isn’t welded to the HRP. I’m not exactly sure what I did wrong though.

1 Like