How to make fireball abilty for boss

This is my current function

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?

1 Like

I would recommend doing it

function Fireballs(boss)

1 Like

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?

1 Like

No something is wrong but i dont know why

1 Like

…can you send the code snippet that calls the boss attack function?

1 Like

Do you call it inside the script or with require from module script?

I also Recommend turning it into either this:

function FireBalls(boss)

or

function BossAttacksFireBalls(boss)

if you call it inside the script itself

local function BossAttacksFireBalls(boss)

--to call would be:
BossAttacksFireBalls(boss)

With require from module scripr

1 Like

How do you call it can you show

1 Like

Let’s first rule out the possibilities:

1. The problem inside the fireball

  1. The script does not launch.
  2. The script detects the boss as a player, thus triggering immediately.
  3. The fireball script has an error.

2. The problem inside the boss script

  1. 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
1 Like

Sure! here is it

local boss = script.Parent
local Attacks = require(game.ReplicatedStorage.BossAttacks)

wait(10)
Attacks.FireBalls(boss)
1 Like

Change your to function name to

BossAttacksFireBalls(boss)
1 Like

Here is how i call the function

local boss = script.Parent
local Attacks = require(game.ReplicatedStorage.BossAttacks)

wait(10)
Attacks.FireBalls(boss
1 Like

Change your to function name to

BossAttacksFireBalls(boss)

and call it

Attacks.BossAttacksFireBalls(boss)

Still didn’t work…Why is this so hard:(

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?

1 Like

Alright

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







1 Like

True I forgot that,
Try

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
1 Like

I think the problem is that you didn’t return the BossAttacks table. Try adding return BossAttacks at the end.

1 Like

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