Boss always throws fireball at same spot

Hello!
I’ve got a problem with my boss’s attack.

So boss can rotate around map and throw fireballs, but he always throws at same spot even if he is rotated

Code:

function fireballSpit()
	local fireball = Instance.new("Part", workspace)
	fireball.Name = "Fireball"
	fireball.BrickColor = BrickColor.new("Neon orange")
	fireball.Material = Enum.Material.Neon
	fireball.CanCollide = true
	fireball.Size = Vector3.new(16,16,16)
	fireball.Shape = "Ball"
	
	local launch = boss.HumanoidRootPart.Position + boss.HumanoidRootPart.CFrame.LookVector * 5 + Vector3.new(0, 25, -25)
	fireball.Position = launch
	
	local vel = Instance.new("BodyVelocity", fireball)
	vel.Velocity = fireball.CFrame.LookVector * 100
	vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	game.Debris:AddItem(vel, 0.25)
	
	local code = codes.Fireball:Clone()
	code.Parent = fireball
	code.Disabled = false
end

Pass boss as an argument.

function fireballSpit(boss)
	local fireball = Instance.new("Part", workspace)
	fireball.Name = "Fireball"
	fireball.BrickColor = BrickColor.new("Neon orange")
	fireball.Material = Enum.Material.Neon
	fireball.CanCollide = true
	fireball.Size = Vector3.new(16,16,16)
	fireball.Shape = "Ball"
	
	local launch = boss.HumanoidRootPart.Position + boss.HumanoidRootPart.CFrame.LookVector * 5 + Vector3.new(0, 25, -25)
	fireball.Position = launch
	
	local vel = Instance.new("BodyVelocity", fireball)
	vel.Velocity = fireball.CFrame.LookVector * 100
	vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	game.Debris:AddItem(vel, 0.25)
	
	local code = codes.Fireball:Clone()
	code.Parent = fireball
	code.Disabled = false
end

Why, that changes nothing everything in one script.
local boss = script.Parent

You only set the fireball’s Position. You’ll need to set its CFrame to change where it moves (since your code uses the orientation of the CFrame to decide where to send it)

function fireballSpit()
	local fireball = Instance.new("Part", workspace)
	fireball.Name = "Fireball"
	fireball.BrickColor = BrickColor.new("Neon orange")
	fireball.Material = Enum.Material.Neon
	fireball.CanCollide = true
	fireball.Size = Vector3.new(16,16,16)
	fireball.Shape = "Ball"
	
	local launch = boss.HumanoidRootPart.CFrame + Vector3.new(0, 25, -25)
	fireball.CFrame = launch
	
	local vel = Instance.new("BodyVelocity", fireball)
	vel.Velocity = fireball.CFrame.LookVector * 100
	vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	game.Debris:AddItem(vel, 0.25)
	
	local code = codes.Fireball:Clone()
	code.Parent = fireball
	code.Disabled = false
end
3 Likes

Thanks, is working now! :smiley:

1 Like