How can I change my aiming script to work for an AimPart rather than trying to guess coordinates?
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.
01 | local PriCF = p.weaponpos |
02 | local PriADS = CFrame.new() |
04 | local SecCF = s.weaponpos |
05 | local SecADS = CFrame.new() |
07 | run.RenderStepped:connect( function () |
08 | guns.Primary:SetPrimaryPartCFrame(cam.CFrame*PriADS) |
09 | guns.Secondary:SetPrimaryPartCFrame(cam.CFrame*SecADS) |
12 | PriADS = PriADS:lerp(p.aimpos, p.zoomspeed) |
13 | SecADS = SecADS:lerp(s.aimpos, . 3 ) |
14 | uis.MouseIconEnabled = false |
16 | if p.weapontype = = "bolt-action" then |
17 | if cam:FindFirstChild(guns.Primary.Name) then |
19 | guns.Primary [ guns.Primary.Name ] .Scope.Transparency = 1 |
20 | player.PlayerGui.HUD.Scope.Frame.Visible = true |
21 | cam.FieldOfView = p.zoom |
28 | PriADS = PriADS:lerp(PriCF,. 2 ) |
29 | SecADS = SecADS:lerp(SecCF, . 3 ) |
30 | uis.MouseIconEnabled = true |
32 | if p.weapontype = = "bolt-action" then |
33 | guns.Primary [ guns.Primary.Name ] .Scope.Transparency = 0 |
34 | player.PlayerGui.HUD.Scope.Frame.Visible = false |
35 | cam.FieldOfView = p.ads |
The weapon module looks like this
Well only a part.
3 | weaponname = script.Parent; |
4 | weaponpos = CFrame.new( 0 ,- 1.5 , 1.2 ); |
5 | aimpos = 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.