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

Strange Lua Table error?

Asked by 7 years ago

In a control script I'm currently working on, a strange error has popped up with the following table:

local Inputs = {
    Enum.KeyCode.Thumbstick2 = GamePadSteer,
    Enum.KeyCode.Thumbstick1 = GamePadTilt,
    Enum.KeyCode.ButtonR2 = GamePadThrottleFoward,
    Enum.KeyCode.ButtonL2 = GamePadThrottleReverse,
    Enum.KeyCode.W = KeyThrottleUp,
    Enum.KeyCode.S = KeyThrottleDown,
    Enum.KeyCode.A = KeySteerLeft,
    Enum.KeyCode.D = KeySteerRight,
    Enum.KeyCode.J = KeyTiltLeft,
    Enum.KeyCode.K = KeyTiltDown,
    Enum.KeyCode.L = KeyTiltRight,
    Enum.KeyCode.I = KeyTiltUp
    }

It throws an error of Controller:167: '}' expected (to close '{' at line 166) near '='

Not sure whats going on and I don't know how to fix it. What do, SH?

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

Assuming all the variables are defined, this is a simple issue:

You need to wrap the 'keys' in brackets, like so: [Enum.KeyCode.Thumbstick2] = GamePadSteer,

This is the same syntactic sugar used for dot notation:

game.Workspace.Model.Part --> game["Workspace"]["Model"]["Part"]
...
{StringKey = "SomeValue"} --> {["StringKey"] = "SomeValue"}
Ad

Answer this question