Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Strange Lua Table error?

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

✓ Accepted answer

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"}

This discussion is preserved as it was. New answers, comments, and votes are closed.