Cant get player mouse. But I defined it. Is this correct? [Unsolved]
Script works, but it's telling me that "18:20:36.041 - Players.Player1.Backpack.Plane.Main:46: attempt to index global 'mouse' (a nil value)" When I Just defined it...
02 | local player = script.Parent.Parent.Parent |
05 | local gyro = script.Parent.Parent.Parent.Character.Real.Main.Gyro |
08 | inputService = game:GetService( "UserInputService" ) |
14 | Player = script.Parent.Parent.Parent |
16 | mouse = Player:GetMouse() |
17 | function onKeyDown(key) |
18 | if not enabled then return end |
26 | local main = script.Parent.Parent.Parent.Character.Real.Main |
27 | local move = script.Parent.Parent.Parent.Character.Real.Main.Move |
28 | move.velocity = (main.CFrame.lookVector + main.CFrame.lookVector*SPEED) |
30 | local bank = ((((m.ViewSizeX/ 2 )-m.X)/(m.ViewSizeX/ 2 ))*maxBank) |
31 | bank = (bank < -maxBank and -maxBank or bank > maxBank and maxBank or bank) |
32 | gyro.maxTorque = Vector 3. new( math.huge , math.huge , math.huge ) |
33 | gyro.cframe = (m.Hit*CFrame.Angles( 0 , 0 ,math.rad(bank))) |
45 | mouse.KeyDown:connect(onKeyDown) |
52 | script.Parent.Selected:connect( function (m) |
54 | game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Attach |
56 | delay( 0 , function () fly(m) end ) |