The problem is in the table
If you gonna make a table it should be like this
local Table = {
1,
2,
true,
false,
function(ToPrint)
print(ToPrint)
end
}
print(Table[1])
print(Table[2])
print(Table[3])
print(Table[4])
print(Table[5]("Hello"))
if you want to name the values ??in the table you would have to name them as if it were a variable
Example
local Table = {
One = 1,
Two = 2,
Three = true,
Four = false,
Five = function(ToPrint)
print(ToPrint)
end
}
print(Table.One)
print(Table.Two)
print(Table.Three)
print(Table.Four)
print(Table.Five("Hello"))
The fixed code should be like this:
local ProductFunctions = {
One = function(player)
if player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.Health = 0
return true
end
end,
}
local Handler = ProductFunctions.One
local S,E = pcall(function()
return Handler(game.Players:WaitForChild('Roblox'))
end)
print(S,E)
Or like this:
local ProductFunctions = {
function(player)
if player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.Health = 0
return true
end
end
}
local Handler = ProductFunctions[1]
local S,E = pcall(function()
return Handler(game.Players:WaitForChild('Roblox'))
end)
print(S,E)