Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I change my aiming script to work for an AimPart rather than trying to guess coordinates?

Asked by 6 years ago

Yea I know the title was hard to explain but here's the truth. The way I use aiming in my script is really bad and I was hoping for some suggestions on how to have a aim part on the gun itself so I don't have to do as much work and it can be much more accurate.

The framework looks like this.

01local PriCF = p.weaponpos
02local PriADS = CFrame.new()
03 
04local SecCF = s.weaponpos
05local SecADS = CFrame.new()
06 
07run.RenderStepped:connect(function()
08    guns.Primary:SetPrimaryPartCFrame(cam.CFrame*PriADS)
09    guns.Secondary:SetPrimaryPartCFrame(cam.CFrame*SecADS)
10 
11    if aiming then
12    PriADS = PriADS:lerp(p.aimpos, p.zoomspeed)
13    SecADS = SecADS:lerp(s.aimpos, .3)
14    uis.MouseIconEnabled = false
15 
View all 41 lines...

The weapon module looks like this Well only a part.

1local s = {
2 
3weaponname = script.Parent;
4weaponpos = CFrame.new(0,-1.5,1.2); -- Position of The Gun In The Cameraz
5aimpos = CFrame.new(-1.15,-.9,2);

The problem is I have to change the aimpos so many times just to try to get it straight but even so it's still not accurate. So any suggestions on how I can make it good enough or if I can use a AimPart to make it much easier. Any help would be appreciated.

1 answer

Log in to vote
0
Answered by
Synth_o 136
6 years ago

Alright so I think you are trying to talk about the scope of a gun, and EgoMoose has written a very good article basically explaining everything you want to know so you should check it out:

https://scriptinghelpers.org/blog/the-first-person-element-of-a-first-person-shooter

Ad

Answer this question