Designing an FPS Framework: Beginner's guide

I did remove that line

^video^

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

I made arms invisible so you can see easier

2 Likes

Does it do the same thing with the groza model?

1 Like

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.

2 Likes

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)

1 Like

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.

1 Like

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.

2 Likes

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

1 Like

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.

1 Like

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
end

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 = Instance.new("Motor6D")
			newMotor.Name = v.Name
			newMotor.Part0 = Main
			newMotor.Part1 = v
			newMotor.C0 = newMotor.Part0.CFrame:inverse() * newMotor.Part1.CFrame
			newMotor.Parent = Main
		end
	end
end

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

return MainModule

lcoal

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

local MainModule = require(game.ReplicatedStorage.MainModule)

ViewModel.Parent = workspace.Camera

game:GetService("RunService").RenderStepped:Connect(function(dt)
	MainModule.update(ViewModel, dt)
end)

MainModule.WeldGun(GunModel)
MainModule.Equip(GunModel, ViewModel)
3 Likes

Do you have a video showing this?

2 Likes

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?

1 Like

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.

1 Like

Okay, I see. Thanks for clarifying.

1 Like

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 = Instance.new("Motor6D")
			NewMotor.Name = v.Name
			NewMotor.Part0 = Main
			NewMotor.Part1 = v
			NewMotor.C0 = NewMotor.Part0.CFrame:inverse() * NewMotor.Part1.CFrame
			NewMotor.Parent = Main
		end
	end
end


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

Do you have any footage showing this?

1 Like

Here is what it looks like in game:

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

1 Like

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

1 Like
function Module.ViewmodelUpdate(Viewmodel, DT)

Viewmodel.HumanoidRootPart.CFrame = workspace.Camera.CFrame

end
1 Like

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

2 Likes

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