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

Could you teach us how to implement a aim system ? I´ve tried with offsets but it is not working :frowning:

1 Like

Update: Added Step 6: Aiming because of demand.

5 Likes

I have some problems with my aiming system, using the same code as you did.

gunmodel.GunComponents.Sight.CFrame = gunmodel.GunComponents.Sight.CFrame:Lerp(viewmodel.HumanoidRootPart.CFrame,game.ReplicatedStorage.Aim.AimValue.Value)
function module.aim(toaim,viewmodel,gun)
	if toaim then
		game:GetService('TweenService'):Create(game.ReplicatedStorage.Aim.AimValue, TweenInfo.new(1),{Value = 1}):Play()
	else
		game:GetService('TweenService'):Create(game.ReplicatedStorage.Aim.AimValue, TweenInfo.new(1),{Value = 0}):Play()
	end
end

Any fixes? Watch this video

3 Likes

You just have to rotate the part so the orientation is correct.

3 Likes

HumanoidRootPart’s Orientation is 0,0,0.

3 Likes

I meant the sight orientation.

4 Likes

My bad, but this is a little too close is there a way to make the arms visible?

5 Likes

Reposition the sight so it is a bit behind than usual

5 Likes

Thanks man, helped me alot keep up with these great tutorials. :smiley:

5 Likes

what value is AimAlpha? a bool, an int?

2 Likes

“AimAlpha” is a Number Value .

3 Likes

Hello,

It appears all the videos are broken for me for both part 1 and 2.

2 Likes

Hey, im not sure why it isnt tweening, ive just started doing the aiming, and I had triple checked this it looks the same as yours, but I’m not sure whats wrong, this is my code.(Also this is just as you start it and get the tween working)
local-

game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		IsPlayerHoldingMouse = true
	end
	
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		
		mainModule.aim(true, Viewmodel, GunModel)
		
	end
end)

game:GetService("UserInputService").InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		IsPlayerHoldingMouse = false
	end
	
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		
		mainModule.aim(false, Viewmodel, GunModel)
		
	end
end)

module-

function module.aim(toaim, viewmodel, gun)
	if toaim then
		game:GetService("TweenService"):Create(game.ReplicatedStorage.Values.AimAlpha, TweenInfo.new(1), { Value = 1 }):Play()

		gun.Components.Sight.CFrame = gun.Components.Sight.CFrame:Lerp(viewmodel.HumanoidRootPart.CFrame, game.ReplicatedStorage.Values.AimAlpha.Value)
	else
		game:GetService("TweenService"):Create(game.ReplicatedStorage.Values.AimAlpha, TweenInfo.new(1), { Value = 0 }):Play()
		
		gun.Components.Sight.CFrame = gun.Components.Sight.CFrame:Lerp(viewmodel.HumanoidRootPart.CFrame, game.ReplicatedStorage.Values.AimAlpha.Value)
	end
end
3 Likes

Alright, that was a mistake on my part. It should be fixed.

4 Likes

For the lerping, you’re supposed to lerp in the .update() like as mentioned:

2 Likes

like this?

function module.update(viewmodel, dt, RecoilSpring, BobbleSpring, SwayingSpring, gun)
	gun.Components.Sight.CFrame = gun.Components.Sight.CFrame:Lerp(viewmodel.HumanoidRootPart.CFrame, game.ReplicatedStorage.Values.AimAlpha.Value)
1 Like

Yeah that seems about correct.

2 Likes

And how can you make a play button and when you click on it, you will get a weapon?
And gun choice.
Im bad programmer… :frowning:

3 Likes

UPDATE: Here are the scripts for you to compare with your own: fpsframeworkscripts.rbxm (5.8 KB). (apologies for not providing this earlier)

5 Likes

This acted as a very helpful tool for me. Haven’t found anything else like it. If possible, and you being a programmer and all, kindle advise the way forward when it comes to adding other weapons to the game. It however seems to be limited to only one gun.
Thanks.

3 Likes