Issue with Rocket launcher

I have recently been working on a brickbattle game. I was working on the rocket launcher but found an issue with the direction of the rocket.

The actual rocket launcher works fine, but when you fire, the rocket doesn’t face the direction you shot it in. image

I have tried moving the fire part (the starting position of the rocket when you fire) but nothing worked.
Client Script:

local function event()
	script.Parent.FireR:FireServer(game.Players.LocalPlayer:GetMouse().Hit.LookVector)
end
script.Parent.Parent.Activated:Connect(event)

Server script:

local db = script.Parent.Debounce
script.Parent.FireR.OnServerEvent:Connect(function(event, position)
	if db.Value == true and script.Parent.Ammo.Value >= 1 then
		db.Value = false
		local rocket = Instance.new("Part", game.Workspace)
		local vel = Instance.new("BodyVelocity", rocket)
		rocket.Color = Color3.new(0, 0.666667, 1)
		rocket.Size = Vector3.new(3,1,1)
		script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
		rocket.CFrame = script.Parent.Parent.FirePart.CFrame
		vel.P = Vector3.new(1000,1000,1000)
		vel.Velocity = position * 100
		local db2 = true
		local bodygyro = Instance.new("BodyGyro", rocket)
		bodygyro.CFrame = rocket.CFrame
		rocket.CanCollide = false
		wait(0.1)
		rocket.Touched:Connect(function(hit1)
			if db2 == true then
				local exp = Instance.new("Explosion", game.Workspace)
				db2 = false
			    exp.Position = rocket.Position
				local db3 = true
				rocket:Destroy()
				exp.DestroyJointRadiusPercent = 0
				exp.Hit:Connect(function(hit2)
					if hit2.Parent:FindFirstChild("Head") and db3 == true then
						if hit2.Parent.Name == script.Parent.Parent.Parent.Name then
							print("No")
						else
							db3 = false
							hit2.Parent.Humanoid.Health = 0
							game.Players[script.Parent.Parent.Parent.Name].leaderstats.KOs.Value = game.Players[script.Parent.Parent.Parent.Name].leaderstats.KOs.Value + 1		
							hit2.Parent.Head.Name = "FakeHead"
					end
				end
				end)
		  end
		end)
	end
end)

Any ideas on how to fix this?

1 Like

Try doing:

script.Parent.FireR:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p - script.Parent.Parent.FirePart.Position).Unit)
2 Likes

I tried it. I think it might work if I change the server script.