Module Code Snippet
if typeof(SpecialEffects) == "table" and table.find(SpecialEffects,AllowedSpecialEffectsTable[6]) then
for Index, value in pairs(SpecialEffects) do
if typeof(value) == "table" and Index == "Instances" then
local NewTable = table.find(SpecialEffects,"Instances")
local Result = table.find(NewTable,parent)
if Result then
NewDamage = Damage * Result
HandleDamage()
else
HandleDamage()
end
else
HandleDamage()
end
end
elseif typeof(SpecialEffects) == "table" and table.find(SpecialEffects,AllowedSpecialEffectsTable[7]) then
print("Passed 2")
local Humanoid = parent:FindFirstChildOfClass("Humanoid")
if Humanoid then
print("0.5")
if Damage == nil then --% Damage Only
local Result1 = table.find(SpecialEffects,"DivideMaxHealth")
print("1")
if Result1 == nil then print(SpecialEffects) return end
print("2")
local Result2 = table.find(SpecialEffects,"MaxHealthDamage")
print("3")
local MoreDamage = nil
NewDamage = Humanoid.MaxHealth / Result1
print("5")
if Result2 then
MoreDamage = NewDamage / Result2
else
MoreDamage = NewDamage
end
print("6")
HandleDamage(true, MoreDamage, Humanoid)
elseif Damage ~= nil then --% Damage + Original Damage
local Result1 = table.find(SpecialEffects,"DivideMaxHealth")
print("1")
if Result1 == nil then print(SpecialEffects) return end
print("2")
local Result2 = table.find(SpecialEffects,"MaxHealthDamage")
print("3")
local MoreDamage = nil
if Result2 then
MoreDamage = (NewDamage / Result2) + Damage
else
MoreDamage = NewDamage + Damage
end
print("4")
HandleDamage(true, NewDamage, Humanoid)
end
end
elseif typeof(SpecialEffects) ~= "table" and Damage ~= nil then
HandleDamage()
else
warn(SpecialEffects)
end
Before I start talking about my problems, I will go into detail about the most important variables to keep track of.
SpecialEffects is a function parameter. It is the table I am trying to find certain values inside.
AllowedSpecialEffectsTable is a already built in ModuleScript table used to idenify if the SpecialEffects parameter table contains one of the strings in the AllowedSpecialEffectsTable.
Now with that out of the way, here’s my problem. When I try checking the type of the SpecialEffects parameter, it returns “never”. This is something I have yet to be able to figure out and I believe I wrote all my if statements conditionals correctly when type-checking the table. I do not know how typeof(SpecialEffects) == "table"
is showing up as a “never” value and it seems odd considering the fact the first if statement was written correctly. I do not know where this issue is located at all besides the very first if statements and elseif statements, which is the problem.
Now, I already tried some solutions. The first one was detecting if the SpecialEffects parameter was nil or not, but the first if statement would NOT run at all regardless, despite there being a table, which makes the parameter not return nil.
For more info, these are the types of tables I am using for the currently built in if statements.
Current Usage of Tables
local AllowedSpecialEffectsTable = {
["Force"] = true; --1
["Grab"] = true; -- 2
["Damage Overtime"] = true;-- 3
["Spawn Extra Attacks"] = true; --4
["Lifesteal"] = true; -- 5
["Reduce Damage for Specific Instances"] = true; -- 6
["Deal Percentage Damage"] = true; -- 7
}
--\\// Reduce Damage for Specific Instances \\//-- --->
local Table = {
{
Name = "Table of Instances"
Instances = { -- Required
[""] = true; --Enter any name here
}
}
}
--\\// Deal Percentage Damage\\//-- --->
local Table = {
{
Name = "Deal Percentage Damage";
DivideMaxHealth = division;
MaxHealthDamage = DivideMaxHealth/division; -- Divide "DivideMaxHealth with whatever"
}
}
I’m out of options. If anybody would like to come help, please do so. Tables in Roblox confuse me the most because of their not-very descriptive nature. I am pretty sure I wrote most of my code correctly, but there is some issue I have yet been able to resolve as a result of the typeof(SpecialEffects) == "table"
problem, which just defaults to printing a warning of the entire SpecialEffects table.