Roblox Combat System Script - Syntax Error: Expected ')' to Close '(' at Line 7), Got ','

This is the script I'm using. Got It from this YouTube video:
.
I've checked and tried to solve this multiple times, can't find my mistake.

Roblox Studio PrtScrn:

local RP = game:GetService("ReplicatedStorage")
local Combat = RP:WaitForChild("Combat")

local Animations = script:WaitForChild("Animations")

local anims = 
    (
        Animations:WaitForChild("RightPunch"), -- error is here.
        Animations:WaitForChild("LeftKnee"),
        Animations:WaitForChild("LeftPunch"),
        Animations:WaitForChild("RightKnee"),
        Animations:WaitForChild("StrongKick"),
    )

Combat.OnServerEvent:Connect(function(player,count)
    local Character = player.Character
    local Humanoid = Character:WaitForChild("Humanoid")
    
    local Attack = Humanoid:LoadAnimation(anims[count])
    Attack:Play()
    
    Combat:FireClient(player)
end)
4

1 Answer

Lua tables are created using the table constructor {}.

The error message is caused by local anims = (Animations:WaitForChild("RightPunch"),

because (expr, is invalid syntax. You cannot have a comma separated list inside parentheses ().

Instead of the expected ) Lua will find a , and complain about it.

But you shouldn't use ( in the first place so that error is just a symptom of your actual mistake.

So the thought process here is:

Why does Lua want me to put a ) where I need a , to separate table items ? And why should that ) close ( in line 7? I don't need ( there, this is not how you create a table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest