Hello, Im currently having an issue passing down a table as an argument to a function in a module im working on.
Whenever i try to pass down a table as an argument it just gives me an error saying its nil " 17:23:48.243 ReplicatedStorage.Main.Modules.ControlsModule:13: invalid argument #1 to ‘pairs’ (table expected, got nil) - Client - ControlsModule:13"
ControlsModule Function:
function Controls:PopulateControls(ControlsTable)
local ControlsDropDown = game.Players.LocalPlayer.PlayerGui.Controls.Frame.Controls
-- Destroying Duplications
for _, ControlName in pairs(ControlsTable) do
for _, TextLabel in pairs(ControlsDropDown:GetChildren()) do
if TextLabel:IsA("TextLabel") and TextLabel.Name == ControlName then
task.spawn(function()
local DisappearTween = TweenService:Create(TextLabel, DisappearTweenInfo, { TextColor = Color3.new(1, 0, 0), TextTransparency = 1, BackgroundTransparency = 1, })
DisappearTween:Play()
local SecondTween = TweenService:Create(TextLabel.TextLabel_Roundify_12px, DisappearTweenInfo, { ImageColor3 = Color3.new(255,0,0), ImageTransparency = 1, })
SecondTween:Play()
SecondTween.Completed:Once(function()
TextLabel:Destroy()
end)
end)
end
end
end
-- Destroying Identical Control Connections
for Key, ControlName in pairs(ControlsTable) do
for ControlConnecName, ControlConnnection in pairs(ControlConnections) do
if ControlName == ControlConnecName then
ControlConnnection:Disconnect()
end
end
end
-- Creating New TextLabels
for Key, ControlName in pairs(ControlsTable) do
local ClonedTextLabel = TextlabelExample:Clone()
ClonedTextLabel.TextTransparency = 1
ClonedTextLabel.TextLabel_Roundify_12px.ImageTransparency = 1
ClonedTextLabel.TextLabel_Roundify_12px.Size = UDim2.new(0,0,0,0)
ClonedTextLabel.Parent = script.Parent.Frame.Controls
local FirstTween = TweenService:Create(ClonedTextLabel.TextLabel_Roundify_12px, AppearTweenInfo, { ImageTransparency = 0, Size = UDim2.new(1,0,1,0) })
FirstTween:Play()
FirstTween.Completed:Once(function()
local SecondTween = TweenService:Create(ClonedTextLabel, AppearTweenInfo, { TextTransparency = 0 })
SecondTween:Play()
ClonedTextLabel.Text = "["..tostring(Key).."]".." "..ControlName
SecondTween.Completed:Once(function()
-- Establish UIS Connection
local db = false
ControlConnections[ControlName] = UIS.InputBegan:Connect(function(input, proc)
if proc then return end
if input.KeyCode == Key and db == false then
print("Same Key")
db = true
local ColorTween = TweenService:Create(ClonedTextLabel, ActivatedTween, { TextColor3 = Color3.new(0.266667, 1, 0.152941) })
ColorTween:Play()
local SecondColorTween = TweenService:Create(ClonedTextLabel.TextLabel_Roundify_12px, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out, 0,true,0), { ImageColor3 = Color3.new(0.223529, 0.639216, 0.176471) })
SecondColorTween:Play()
task.spawn(function()
task.wait(1.5)
db = false
end)
end
end)
end)
end)
end
end
ClientScript:
local Module = require(game.ReplicatedStorage.Main.Modules.ControlsModule)
task.wait(6)
Module.PopulateControls({
[Enum.KeyCode.E] = "Equip"
})
Lemme know if theres a way to solve this, Thank you for your time.