I’m making a tower defense game so I want to make a tower that throws a fireball that pierces enemies.
-
What is the issue?
I’m using a module script to make the shoot system and once the fireball hits its target it destroys itself but I want it to just pierce the enemy and continue on its way for a couple of seconds (in the same direction) like this:
(that character at the left is my tower and that thing at the right is the fireball) -
What solutions have you tried so far?
I tried to set a position a little further from its target, like target.Torso.Position.X + 50, but it keeps going to a specific position and not in the target direction.
This is my code:
local p = Instance.new("Part", workspace)
p.CFrame = CFrame.lookAt(newTower.Gun.Position, Vector3.new(target.HumanoidRootPart.Position.X, newTower.HumanoidRootPart.Position.Y, target.HumanoidRootPart.Position.Z))
p.Anchored = true
p.Shape = Enum.PartType.Ball
p.Material = Enum.Material.Neon
p.CanCollide = false
p.Size = Vector3.new(1.65, 0.35, 1.65)
-- here is where I have problems
local newPos = Vector3.new(target.HumanoidRootPart.Position.X + 50, newTower.HumanoidRootPart.Position.Y, target.HumanoidRootPart.Position.Z)
local TweenService = game:GetService("TweenService")
local pTween = TweenService:Create(p, TweenInfo.new(0.85), {Position = newPos})
pTween:Play()
(btw, newTower.Gun is the neon ball of the tower)
If anyone can help me please, thanks!
(this is my first post in the forum btw)