So every function that I put this this module script seems to always have “self: the module’s name” first.
and I can’t find a way to not make that happen, and it would be so nice if someone would spot out a solution for me.
Here’s my modulescript if you wanna look through it. I know it looks a lot, but everything works aside from the functions.
local AttackEngine = {}
local MainModule = {
["GeneralStats"] = {
-- General Stats
["Monitor Head"] = {
["Name"] = "MONITORHEAD",
["Type"] = "Electric",
["HP"] = 175,
["Gender"] = "Male",
["Stage"] = "1",
["Icons"] = {
["PlayerSide"] = {
["Normal"] = "rbxassetid://12234029454",
["Low Health"] = "rbxassetid://12234029987"
},
["EnemySide"] = {
["Normal"] = "rbxassetid://12228142775",
["Low Health"] = "rbxassetid://12220795632"
}
}
},
["Toast"] = {
["Name"] = "TOAST",
["Type"] = "Electric",
["HP"] = 150,
["Gender"] = "Male",
["Stage"] = "1",
["Icons"] = {
["PlayerSide"] = {
["Normal"] = "rbxassetid://12220791434",
["Low Health"] = "rbxassetid://12229665036"
},
["EnemySide"] = {
["Normal"] = "rbxassetid://12234146928",
["Low Health"] = "rbxassetid://12234147496"
}
}
},
["Snortoise"] = {
["Type"] = "Water",
["HP"] = 175,
["Gender"] = "Male",
["Stage"] = "1"
}
},
}
-- Attack Function !!
function MainModule:Attack(name)
if MainModule[name] == "Monitor Head" then
local AttackMoveRandom = math.random(1,2)
if AttackMoveRandom == 1 then
local Text = "MONITORHEAD used Flash!"
MainModule.Text(Text)
-- Flash
wait(2)
local Miss = math.random(1,5)
if Miss == 3 then
-- Missed
local Text = "MONITORHEAD missed!"
MainModule.Text(Text)
elseif Miss == 1 or 2 then
-- Hit
local CriticalChance = math.random(1,5)
if CriticalChance == 5 then
-- Critical Hit
local Text = "Critical Hit!"
MainModule.Text(Text)
local DMG = math.random(40,55)
elseif CriticalChance == 1 or 2 or 3 or 4 then
-- Normal Hit
local DMG = math.random(10,25)
local Text = "TOAST has been hit!"
MainModule.Text(Text)
end
end
elseif AttackMoveRandom == 2 then
local Text = "MONITORHEAD used Antenna Strangle!"
MainModule.Text(Text,Text)
-- Antenna Strangle
wait(2)
local Miss = math.random(1,5)
if Miss == 3 then
-- Missed
local Text = "MONITORHEAD missed!"
MainModule.Text(Text,Text)
elseif Miss == 1 or 2 then
-- Hit
local CriticalChance = math.random(1,5)
MainModule.Text(Text,Text)
if CriticalChance == 5 then
-- Critical Hit
local Text = "Critical Hit!"
MainModule.Text(Text,Text)
local DMG = math.random(20,30)
elseif CriticalChance == 1 or 2 or 3 or 4 then
-- Normal Hit
local also = workspace.BattleInfo.PlayerSide:WaitForChild("NameValue").Value
local DMG = math.random(10,20)
local Text = also .. " has been hit!"
MainModule.Text(Text,Text)
end
end
end
elseif MainModule[name] == "Toast" then
local Icon = game.StarterGui.ScreenGui.Frame.PlayerIcon
local EndPos = UDim2.new(-0.007, 0,0.413, 0)
local AttackPos = UDim2.new(0.082, 0,0.302, 0)
Icon:TweenPosition(AttackPos,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.45,true)
wait(0.45)
Icon:TweenPosition(EndPos,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.45,true)
local Text = "TOAST used Malted Rye!"
-- Flash
MainModule.Text(Text,Text)
wait(2)
local Miss = math.random(1,5)
if Miss == 3 then
-- Missed
local Text = "TOAST missed!"
MainModule.Text(Text,Text)
elseif Miss == 1 or 2 then
-- Hit
local CriticalChance = math.random(1,5)
if CriticalChance == 5 then
-- Critical Hit
local Text = "Critical Hit!"
game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value = game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value - math.random(30,45)
MainModule.Text(Text,Text)
elseif CriticalChance == 1 or 2 or 3 or 4 then
-- Normal Hit
local Text = "MONITORHEAD has been hit!"
game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value = game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value - math.random(20,25)
MainModule.Text(Text,Text)
end
end
elseif MainModule[name] == "DamagedToast" then
local Icon = game.StarterGui.ScreenGui.Frame.PlayerIcon
local EndPos = UDim2.new(-0.007, 0,0.413, 0)
local AttackPos = UDim2.new(0.082, 0,0.302, 0)
Icon:TweenPosition(AttackPos,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.45,true)
wait(0.45)
Icon:TweenPosition(EndPos,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.45,true)
local Text = "TOAST used Charred Pumpernickel!"
-- Flash
MainModule.Text(Text,Text)
wait(2)
local Miss = math.random(1,5)
if Miss == 3 then
-- Missed
local Text = "MONITORHEAD missed!"
MainModule.Text(Text,Text)
elseif Miss == 1 or 2 then
-- Hit
local CriticalChance = math.random(1,5)
if CriticalChance == 5 then
-- Critical Hit
local Text = "Critical Hit!"
game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value = game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value - math.random(40,45)
MainModule.Text(Text,Text)
elseif CriticalChance == 1 or 2 or 3 or 4 then
-- Normal Hit
local Text = "MONITORHEAD has been hit!"
game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value = game.Workspace.BattleInfo.EnemySide:WaitForChild("HealthValue").Value - math.random(20,25)
MainModule.Text(Text,Text)
end
end
end
end
function MainModule:Text(text)
for i = 1, #text do
game.StarterGui.ScreenGui.Frame.TextFrame.TextLabel.Text = string.sub(text, 1, i)
if string.sub(text, i, i) == "." then
wait(0.3)
end
wait(0.04)
end
function MainModule:GetBattleInfo(Name, Enemy)
if MainModule[Name] == "Monitor Head" and Enemy then
local HealthValue = Instance.new("NumberValue")
local NameValue = Instance.new("StringValue")
NameValue.Parent = workspace.BattleInfo.EnemySide
NameValue.Value = MainModule.GeneralStats["Monitor Head"].Name
HealthValue.Parent = workspace.BattleInfo.EnemySide
HealthValue.Value = MainModule.GeneralStats["Monitor Head"].HP
elseif MainModule[Name] == "Monitor Head" and not Enemy then
local HealthValue = Instance.new("NumberValue")
local NameValue = Instance.new("StringValue")
NameValue.Parent = workspace.BattleInfo.Parent
NameValue.Value = MainModule.GeneralStats["Monitor Head"].Name
HealthValue.Parent = workspace.BattleInfo.PlayerSide
HealthValue.Value = MainModule.GeneralStats["Monitor Head"].HP
elseif MainModule[Name] == "Toast" and Enemy then
local HealthValue = Instance.new("NumberValue")
local NameValue = Instance.new("StringValue")
NameValue.Parent = workspace.BattleInfo.EnemySide
NameValue.Value = MainModule.GeneralStats.Toast.Name
HealthValue.Parent = workspace.BattleInfo.EnemySide
HealthValue.Value = MainModule.GeneralStats.Toast.HP
elseif MainModule[Name] == "Toast" and not Enemy then
local HealthValue = Instance.new("NumberValue")
local NameValue = Instance.new("StringValue")
NameValue.Parent = workspace.BattleInfo.PlayerSide
NameValue.Value = MainModule.GeneralStats.Toast.Name
HealthValue.Parent = workspace.BattleInfo.PlayerSide
HealthValue.Value = MainModule.GeneralStats.Toast.HP
end
end
end
function MainModule:DeleteBattleInfo()
local PlrValues = workspace.BattleInfo.PlayerSide
local EnemyValues = workspace.BattleInfo.EnemySide
PlrValues:ClearAllChildren()
EnemyValues:ClearAllChildren()
end
return MainModule