Hello!
I am attempting to advance the vfx in my wip tower defense game. Initially, when the towers attacked they would just use the default roblox fire as a trail and it worked fine.
-- ORIGINAL CODE
local function fireProjectile(tower, target)
local projectile = Instance.new("Part")
projectile.Size = Vector3.new(1,1,1)
projectile.CFrame = tower.Head.CFrame
projectile.Anchored = true
projectile.CanCollide = false
projectile.Transparency = 1
projectile.Parent = workspace.Camera
local fire = Instance.new("Fire")
fire.Size = 2
fire.Heat = 0.1
fire.Color = tower.Config.Trail.Value
fire.Parent = projectile
local projectileTween = TweenService:Create(projectile, TweenInfo.new(0.3), {Position = target.HumanoidRootPart.Position})
projectileTween:Play()
Debris:AddItem(projectile, 0.3)
end
Then I decided that I wanted to upgrade the effects, my plan for this was to use a particle emitter instead of fire. But I can’t get it to move towards the mobs.
It just teleports towards them, this is the updated code:
--UPDATED CODE
local function fireProjectile(tower, target)
local projectile = Instance.new("Part")
local distance = (tower.Head.Position - target.HumanoidRootPart.Position).Magnitude
projectile.Size = Vector3.new(1,1,1)
projectile.CFrame = tower.Head.CFrame
projectile.Anchored = true
projectile.CanCollide = false
projectile.Transparency = 1
projectile.Parent = workspace.Camera
local emitter = Instance.new("ParticleEmitter")
emitter.Texture = "rbxassetid://12390113643"
emitter.Size = NumberSequence.new(2)
emitter.Squash = NumberSequence.new(-0.3)
emitter.Rate = 5
emitter.Speed = NumberRange.new(15, 30)
emitter.LightEmission = 1
emitter.LightInfluence = 0
emitter.Parent = projectile
emitter.SpreadAngle = Vector2.new(-360, 360)
emitter.FlipbookMode = Enum.ParticleFlipbookMode.OneShot
emitter.FlipbookLayout = Enum.ParticleFlipbookLayout.Grid8x8
emitter.Lifetime = NumberRange.new(1,1)
local projectileTween = TweenService:Create(projectile, TweenInfo.new(0.3), {Position = target.HumanoidRootPart.Position})
projectileTween:Play()
Debris:AddItem(projectile, 0.31)
end
I’m not sure as to why it worked with the fire and not the particle emitter, my best guess is that it has something to do with the tween.
Specifically this line here
local projectileTween = TweenService:Create(projectile, TweenInfo.new(0.3), {Position = target.HumanoidRootPart.Position})
Any help is appreciated!