Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change the direction that the bullet shoots in?

local Damage = 50
local HeadshotDamage = 100

script.Parent.FireEv.OnServerEvent:Connect(function(Player, Shooter, MousePos)
	script.Parent.FirePart.Fire:Play()
	local Bullet = Instance.new("Part", workspace)
	Bullet.CFrame = script.Parent.FirePart.CFrame
	Bullet.Orientation = Bullet.Orientation + Vector3.new(0, 90, 0)
	Bullet.Size = Vector3.new(0.75, 0.15, 0.15)
	Bullet.BrickColor = BrickColor.new("Bright yellow")
	Bullet.TopSurface = "Smooth"
	Bullet.BottomSurface = "Smooth"
	Bullet.Material = "Neon"
	Bullet.CanCollide = false
	local BVol = Instance.new("BodyVelocity", Bullet)
	BVol.P = 100
	Bvol.Velocity = MousePos
	local I = 0
	while I > 100 do
		Bullet.Touched:Connect(function(Toucher)
			if Toucher.Parent == Shooter then return end
			local Hum = Toucher.Parent.Humanoid
			if not Hum then return end
			if Toucher.Name == "Head" then
				Hum:TakeDamage(HeadshotDamage)
			else
				Hum:TakeDamage(Damage)
			end
		end)
		I = I + 1
		wait()
	end
	Bullet:Destroy()
end)

I'm using BodyVelocity (I know it's bad but it's what I know for now) to move the bullet around. When I try to fire it up, it simply continues pushing forwards instead of moving upwards. It seems to actually change its power depending on where the mouse is. How can I fix this mistake?

1 answer

✓ Accepted answer

Just replace the BodyVelocity with BodyForce its a bit different but the reason your bullet will only shoot in a straight line is because BodyVelocity moves objects in local space and not with a quaternion

This discussion is preserved as it was. New answers, comments, and votes are closed.