Why does aim script phase in and out of changing the FOV?
Hi! I made an aim script for a raycast gun and for some unknown reason it randomly will phase in and out of aiming and sometimes not aim at all on certain guns. Some tools work, some don't.
Here is the localscript that handles all of it. (Mousebutton2 Up/Down and the while true are the important ones)
02 | local cc = game.Workspace.CurrentCamera |
04 | local Player = game.Players.LocalPlayer |
05 | local AmmoGui = script.Parent.AmmoGUI:Clone() |
06 | idleAnim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Idle) |
07 | fireAnim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Fire) |
08 | AmmoGui.Parent = Player.PlayerGui |
09 | AmmoGui.TextLabel 1. LocalScript.Disabled = false |
10 | AmmoGui.TextLabel 2. LocalScript.Disabled = false |
13 | mouse.Button 1 Down:connect( function () |
14 | print ( "Mouse pressed client!" ) |
15 | if script.Parent.Ammo.Value > 0 and script.Parent.IsReloading.Value = = false and script.Parent.IsFiring.Value = = false then |
17 | script.Parent.RemoteEvent:FireServer(mouse.Hit) |
22 | mouse.Button 2 Down:connect( function () |
23 | print ( "Mouse pressed client!" ) |
36 | mouse.Button 2 Up:connect( function () |
37 | print ( "Mouse pressed client!" ) |
44 | function UnEquip(mouse) |
46 | local Player = game.Players.LocalPlayer |
47 | Player.PlayerGui.AmmoGUI:Destroy() |
48 | local cc = game.Workspace.CurrentCamera |
55 | script.Parent.Unequipped:Connect(UnEquip) |
56 | script.Parent.Equipped:Connect(Equip) |
59 | if (cc.focus.p - cc.CoordinateFrame.p).magnitude < = 1 then |