What do you want to achieve?
I just trying to fire a projectile in the direction my player is looking at.
What is the issue?
No matter what I do I can’t seem to get the projectile to fire straight. I’m not really sure why. It fires straight down or behind the player. If I Anchor the projectile, it is shows that it is positioned exactly at the humanoid position and facing the correct direction. But does not fly straight forward when I apply the body mover.
What solutions have you tried so far?
I tried to look this problem up as I know lots of folks have projectiles in their games. But either my brain just isn’t working today or I’m missing something. I’m trying to do this via BodyVelocity body mover.
Here is my code:
-- Fire Missile -- local function fireMissile(player) print(player.Name.." Firing Missile["..#missiles.."]") --Grab one of the missiles and remove from missiles array (pop) local missile = table.remove(missiles) local newMissile = missile:Clone() newMissile.Parent = game.Workspace newMissile.Anchored = false missile:Destroy() newMissile.CFrame = CFrame.new(character.HumanoidRootPart.Position, character.HumanoidRootPart.CFrame.LookVector) --Add Particle Emitter to make a missile trail local emitter = Instance.new("ParticleEmitter", newMissile) emitter.Color = ColorSequence.new(Color3.new(0,255,0), Color3.new(255,255,255)) emitter.Size = NumberSequence.new(1, 0) emitter.LockedToPart = true emitter.VelocityInheritance = 1 emitter.EmissionDirection = "Back" emitter.Lifetime = NumberRange.new(1) emitter.Rate = 1000 emitter.Speed = NumberRange.new(25) -- --Do Projectile Code with that missile!!! -- local bodyVelocity = Instance.new("BodyVelocity", newMissile) bodyVelocity.Velocity = newMissile.CFrame.LookVector * 50 newMissile:SetNetworkOwner(nil) --Destroy that missile (for now) newMissile:Destroy() --Check if we are now out of missiles --if so, destory this tool! if(#missiles == 0)then missilesTool:Destroy() end end missileFireEvent.OnServerEvent:Connect(fireMissile)