Orb projectile immediately goes down

Hey, so recently I’ve started working on a small project. The point is to make it so when you press E a big orb comes out in front of you and it damages any players in it’s path. The thing is that the orb always goes down for whatever reason, here’s an example of what I’m talking about:
https://gyazo.com/a5531b11fda550c460be4b78e8261181

I’ve tried using math.Angles() and changing the rotation of the new part after it was created but neither worked and instead they made the orb fire from the origin point, I’ve tried changing the velocity so it’s higher incase gravity is pulling it down but nothing changed and I’ve tried to use different orb models, all of which suffered from the same issue.

If anyone can help me, then here’s the code:

(Client):

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
			print(game.Players.LocalPlayer.Character.Head.CFrame.RightVector)
			game.ReplicatedStorage.Gunshot:FireServer(game.Players.LocalPlayer.Character.Head.CFrame.RightVector)
	end
end)

(Server):

game.ReplicatedStorage.Gunshot.OnServerEvent:Connect(function(player, lookVector)
	print(lookVector)
	local debounce = true
	local newFire = game.ReplicatedStorage.Part:Clone()
	newFire.Position = player.Character.Head.Position
	newFire.Parent = workspace
	local bodyVelocity = Instance.new("BodyVelocity",newFire)
	bodyVelocity.P = Vector3.new(10000,10000,10000)
	bodyVelocity.MaxForce = Vector3.new(10000,10000,10000)
	bodyVelocity.Velocity = lookVector * 300
		newFire.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if hit.Parent.Name ~= player.Name then
				if debounce then
					debounce = false
					for i = 1,5,1 do
						wait(1)
						hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 10
						end
						wait(3)
					debounce = true
					wait(1)
					newFire:Destroy()
				end
			end
		end
	end)
end)
1 Like

This stuff isn’t really in my ballpark yet, but I’ll do my best to help. From what I understand of what the body velocity object and what you have is that P which is your power which determines how fast (technically, how much force is applied) you want your base part (your projectile) to reach your goal velocity, which is determined by bodyVelocity.Velocity. bodyVelocity.MaxForce establishes the maximum amount of force P can apply.

So, because your P is the same as your MaxForce, it just goes a little bit due to the client-server lag (??? not entirely sure) then just falls. The projectiles can never reach the targeted velocity because the max force is equal to the power initially exerted onto the part, canceling it out.

Again, not entirely sure, I’m still learning lua, but I know a little physics.

If that doesn’t solve the problem, I do know of a few settlements that need our help. links that can help you out.

I’ll probably be reading them soon as well anyway.

As far as I remember, the P property takes a number and not a Vector3.

Correct, but since P needs to know which axis to apply force on it needs to utilize vector3

Pretty sure this is just a case of gravity doing what gravity does best. Your power isn’t enough to overcome it because you set P to a Vector3 (it should be a number like another replier mentioned) so you’re ending up with a really weak or possibly the default power value - it’s not enough to overcome the force of gravity.

Thanks for the help! By setting the P slightly higher and the max velocity much higher I had managed for it to travel at a fine speed without going down at all! The orb flew to directions which I hadn’t instructed it to so I switched the place which it comes from so it now comes out of the Humanoid Root Part and it travels in a fixed line.