Anyone know why when I print module.Abilities, it's an empty table?

local module = {}

module.Abilities = {E = module.SigmaSmash}

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild(“HumanoidRootPart”)

function module.SigmaSmash()
task.wait(0.5)
game.ReplicatedStorage.Remotes.Sigma:FireServer()
print(“yo”)
end

return module

this statement is run before you define module.SigmaSmash, so when you run this statement, the key E references nil because module.SigmaSmash is not defined, so it won’t show up in the table because a nil key indicates that the key does not exist (in Luau).

To fix this, you can assign the keys after, or if you only plan to call them through abilities, just do:

function module.E()
    --...
end

Assigning the keys after:

local module = {}

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")

function module.SigmaSmash()
    task.wait(0.5)
    game.ReplicatedStorage.Remotes.Sigma:FireServer()
    print("yo")
end

module.Abilities = {
    E = module.SigmaSmash
}

return module

In the future, please format your code using the code snippets. You can use 3 backticks (`) at the top and bottom of your snippet, or press the </> button in your post editor topbar. It just makes it more readable!

2 Likes

Try this.

local module = {}



local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild(“HumanoidRootPart”)

function module.SigmaSmash()
task.wait(0.5)
game.ReplicatedStorage.Remotes.Sigma:FireServer()
print(“yo”)
end
module.Abilities = {E = module.SigmaSmash}
return module