function BossAttacks.FireBalls(boss)
local fireball = game.ReplicatedStorage.FireBall:Clone()
fireball.Parent = workspace
fireball.Position = boss.PrimaryPart.Position
local Direction = char.PrimaryPart.Position - boss.PrimaryPart.Position
local velo = fireball.LinearVelocity
velo.LineDirection = Direction
velo.LineVelocity = 1000
end
if the function is done then just fire it whenever you want the boss to do that attack. animate the boss and maybe add VFX details. Or are you asking to improve / develop your function?
Maybe it’s included inside a module, so they can reuse it multiple times.
Since this is in “Help and Feedback”, maybe something is wrong?
Maybe try:
function BossAttacks:FireBalls(boss)
local fireball = game.ReplicatedStorage.FireBall:Clone()
fireball.Parent = workspace
fireball.Position = boss.PrimaryPart.Position
local Direction = char.PrimaryPart.Position - boss.PrimaryPart.Position
fireball.LinearVelocity.LineDirection = Direction
fireball.LinearVelocity.LineVelocity = 1000
end
Or did they meant to post a tutorial but sent it to the wrong channel?
The script detects the boss as a player, thus triggering immediately.
The fireball script has an error.
2. The problem inside the boss script
Incorrectly requiring the module
– The functions did not return
– Missing context (using module object instead of original script object)
– Attempting to call variables outside of scope
I think their original one does work, since module.f and module:f both calls the module functions. It’s just that we’re missing a lot of contexts here. Could you show the code snippet of the fireball or the full boss code snippet?
local BossAttacks = {}
local pathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local char = game.Players.LocalPlayer.Character
function BossAttacks.SummonMinions(boss)
local zombies = {game.Workspace["Zombie-Type-1"], game.Workspace["Zombie-Type-32"]}
local clones = 10
repeat
for i, v in pairs(zombies) do
local clone = v:Clone()
clone.Parent = workspace
clone:PivotTo(boss.PrimaryPart.CFrame)
clones -= 1
end
until clones == 0
end
function BossAttacks.FireBalls(boss)
local fireball = game.ReplicatedStorage.FireBall:Clone()
fireball.Parent = workspace
fireball.Position = boss.PrimaryPart.Position
local Direction = char.PrimaryPart.Position - boss.PrimaryPart.Position
local velo = fireball.LinearVelocity
velo.LineDirection = Direction
velo.LineVelocity = 1000
end
function module:BossAttacksFireBalls(boss)
local fireball = game.ReplicatedStorage.FireBall:Clone()
fireball.Parent = workspace
fireball.Position = boss.PrimaryPart.Position
local Direction = char.PrimaryPart.Position - boss.PrimaryPart.Position
local velo = fireball.LinearVelocity
velo.LineDirection = Direction
velo.LineVelocity = 1000
end
Still didn’t work, but anyways let me show you the new updated code
local BossAttacks = {}
local pathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local char = game.Players.LocalPlayer.Character
function BossAttacks.SummonMinions(boss)
local zombies = {game.Workspace["Zombie-Type-1"], game.Workspace["Zombie-Type-32"]}
local clones = 10
repeat
for i, v in pairs(zombies) do
local clone = v:Clone()
clone.Parent = workspace
clone:PivotTo(boss.PrimaryPart.CFrame)
clones -= 1
end
until clones == 0
end
function BossAttacks:BossAttacksFireBalls(boss)
local fireball = game.ReplicatedStorage.FireBall:Clone()
fireball.Parent = workspace
fireball.Position = boss.PrimaryPart.Position
local Direction = char.PrimaryPart.Position - boss.PrimaryPart.Position
local velo = fireball.LinearVelocity
velo.LineDirection = Direction
velo.LineVelocity = 1000
end
return BossAttacks