alright so, i have been trying to program a boss fight, how would i program a boss fight? i tried this and it isnt working,
what im trying to do is have functions inside of a module and the local script makes the boss randomly do those module functions.
this is a localscript inside of the boss and there is a module under it
(im not asking for help on how to make the functions for the boss, im asking for help on how to make the localscript do the thing in the modulescript)
local BossAttacksFoip = require(script.BossAttacksFoip)
task.wait(3)
BossAttacksFoip.AngryFace()
this is the module under the local script
local BossAttacksFoip = {}
BossAttacksFoip.__index = BossAttacksFoip
function BossAttacksFoip.Stomping()
task.wait(0.01)
print("NOT FUNCTIONAL YET! 1")
end
function BossAttacksFoip.Stomping2()
task.wait(0.01)
print("NOT FUNCTIONAL YET! 2")
end
function BossAttacksFoip.Stomping3()
task.wait(0.01)
print("NOT FUNCTIONAL YET! 3")
end
function BossAttacksFoip.LaughingLOL()
task.wait(0.01)
print("NOT FUNCTIONAL YET! 3")
end
function BossAttacksFoip.AngryFace()
task.wait(0.1)
script.Parent.Parent.Parent.billboard.normal.Visible = false
script.Parent.Parent.Parent.billboard.angry.Visible = true
end
function BossAttacksFoip.StopAngryFace()
task.wait(0.1)
script.Parent.Parent.Parent.billboard.normal.Visible = true
script.Parent.Parent.Parent.billboard.angry.Visible = false
end
function BossAttacksFoip.StartCutscene()
task.wait(1)
print("lol")
end
Sup, so I have some few questions. First why are you indexing __index in the table? I see that you never set the metatable for that table which means it is just a normal key.
Another thing, you never return the module by what I am seeing, at the end of the module do this:
You can use math.Random to get a random number, then use one of those numbers as a way to choose which attack the boss does.
(scroll down and find the part about math.Random on the api page: math)
A quick example of what I mean:
local function IceAttack()
print("ICE!")
end
local function FireAttack()
print("FIRE!")
end
local function ThunderAttack()
print("THUNDER!")
end
local whichAttackShouldGo = math.random(1,3)
if whichAttackShouldGo == 1 then
IceAttack()
elseif whichAttackShouldGo == 2 then
FireAttack()
elseif whichAttackShouldGo == 3 then
ThunderAttack()
end
Edit:
For connecting stuff between server scripts and local scripts you can use RemoteEvents. I beleive the same would work for module scripts to local scripts and vice versa, but I haven’t really used module scripts that much so I don’t know.