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

Arithmetic Error? [Solved]

Asked by 10 years ago

Im trying to make this plane Bank in the direction of the mouse. But I get this error on line 9

"15:13:06.446 - Players.Player1.Backpack.Plane.Main:10: attempt to perform arithmetic on global 'maxBank' (a nil value)"

wait(0.1)   -- Yes, this is needed. If it's not here, the plane will only work once.
local player = script.Parent.Parent.Parent
local mouseSave
local maxbank = 90
local gyro = script.Parent.Parent.Parent.Character.Real.Main.Gyro

function fly(m) -- Main function that controls all of the flying stuff. Very messy.
    while true do
        local bank = ((((m.ViewSizeX/2)-m.X)/(m.ViewSizeX/2))*maxBank)  -- My special equation to calculate the banking of the plane. It's pretty simple actually
        bank = (bank < -maxBank and -maxBank or bank > maxBank and maxBank or bank)
            gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
            gyro.cframe = (m.Hit*CFrame.Angles(0,0,math.rad(bank)))
            wait()
        end
        wait()
    end

script.Parent.Selected:connect(function(m)  -- Initial setup
    mouseSave = m
    game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Attach
    m.Icon = "http://www.roblox.com/asset/?id=48801855" -- Mouse icon used in Perilous Skies
    delay(0,function() fly(m) end)  -- Basically a coroutine
    end)

2 answers

Log in to vote
1
Answered by 10 years ago

You forgot to capitalize bank at local maxbank

0
LOL dont I feel stupid... Orlando777 315 — 10y
Ad
Log in to vote
2
Answered by 10 years ago

You made a syntax error. You were trying to perform arithmetic on maxBank, when the variable name is actually maxbank. The "b" in the variable name is actually lowercase.

Answer this question