Making the bullet go directly fowards

  1. What do you want to achieve?
    For the MusketBall to go directly forward. Right now it can only go Infront or behind, not left or right, 45 degrees etc
  2. What is the issue?
    I can’t tell how to do this - nobody has ran into this before
  3. What solutions have you tried so far?
    Again, nobody as had this issue before. I can’t find any posts or DevHub posts about it.
local MainModule = {}

	function MainModule.Fire(Gun)
		local PlayersService = game:GetService("Players")
		local ReplicatedStorageService = game:GetService("ReplicatedStorage")

		Gun.MusketBall.Position += Vector3.new(0, 0, math.random(-3, 3)) --I know about this (Not about my topic)

	Gun.MusketBall.Anchored = false
	if Gun.Union.Orientation.Y > 0 and  Gun.Union.Orientation.Y <= 180 then
		Gun.MusketBall.LinearVelocity.VectorVelocity = Vector3.new(-5,0,0)
	else
		Gun.MusketBall.LinearVelocity.VectorVelocity = Vector3.new(500,0,0)
	end
		Gun.MusketBall.LinearVelocity.Enabled = true

	local otherPart = Gun.MusketBall.Touched:Wait()
	print(otherPart)

		if PlayersService:GetPlayerFromCharacter(otherPart.Parent) then
			otherPart.Parent.Humanoid:TakeDamage(1000)
			ReplicatedStorageService.MusketBallHit:FireAllClients(Gun, "HitFlesh")
			task.wait(0.5)
			Gun.MusketBall.Anchored = true
		Gun.MusketBall.LinearVelocity.Enabled = false
		task.wait(3.5)
		--Gun.MusketBall:Destroy()
		elseif otherPart.Material == Enum.Material.Metal then 
			ReplicatedStorageService.MusketBallHit:FireAllClients(Gun, "HitMetal")
			task.wait(0.2)
			Gun.MusketBall.Anchored = true
		Gun.MusketBall.LinearVelocity.Enabled = false
		task.wait(3.8)
		--Gun.MusketBall:Destroy()
		end

	end



return MainModule

If you want change the Position and Orientation of your parts, probably you must be use the ‘renderstepped’ and ‘heartbeat’ events of ‘run service’, and modify the CFrame (with CFrame.new and CFrame.Angles) instead ‘Vector3’.

Gun.MusketBall.LinearVelocity.VectorVelocity = Gun.Union.CFrame.LookVector * 500

You may need to switch LookVector with RightVector or UpVector, and maybe add a negative sign, depending on your exact setup.

2 Likes

I had to use RightVector, but it fixed it.
I love people like you, made my day.

2 Likes

In a perfect world developers would keep their physical instances oriented to Vector3.new(0, 0, 0), that way it’d be LookVector every time.

2 Likes