If you haven’t solved the issue that the ball isn’t rising, I think I know the reason and a solution to that. In the line of code you put in the reply to emojipasta, you multiplied the LookVector with Vector3.new(300, 1000, 300). When calculating the velocity this way, the x and z coordinates will be what you want them to be, but if you want the ball to go higher than the LookVector of the HumanoidRootPart, it won’t work.
Here’s the reason: When the character is upright, the Y value in the LookVector of the HumanoidRootPart is always 0. When you multiply the LookVector with the other Vector, you get a Vector3 where
X = LookVector.X*300, Y = LookVector.Y*1000, Z = LookVector.Z*300
Because LookVector.Y is 0, the Y in your Velocity Vector is 0*1000 which is 0.
Instead of calculating the Velocity that way, maybe do it like this:
local SPEED = 300 -- how many studs the ball moves in one second
local ANGLE_IN_DEGREES = 40 -- How many degrees you want it to rise
-- Roblox functions use radians instead of degrees,
-- so degrees need to be converted to radians for the calculations
local angle = math.rad(ANGLE_IN_DEGREES)
local lookVector = player.Character.HumanoidRootPart.CFrame.LookVector
-- the ratio of the calculated x and z will be the same as the ratio of these,
-- so the horizontal direction will be the same as the direction of the HumanoidRootPart
local lookX, lookZ = lookVector.X, lookVector.Z
-- these are used to turn the x and/or z to negative
-- if the corresponding lookVector coordinate is negative
local xm, zm = lookX < 0 and -1 or 1, lookZ < 0 and -1 or 1
-- turn these into their absolute values to make the calculations wont give any NAN values
lookX, lookZ = math.abs(lookVector.X), math.abs(lookVector.Z)
-- calculating the new direction values
local newX, newY, newZ
if lookX == 0 or lookZ == 0 then
if lookX == 0 then
newX = 0
newZ = math.cos(angle)
else newX = math.cos(angle)
newZ = 0
end
newY = math.sin(angle)
else newX = math.abs((math.cos(angle)*lookX)/math.sqrt(lookX^2+lookZ^2))
newZ = math.abs(lookZ/lookX*newX)
newY = math.tan(angle)*math.sqrt(newX^2+newZ^2)
end
-- make the values negative if the corresponding coordinate is negative in the lookVector
newX, newZ = newX*xm, newZ*zm
-- This is a unit Vector, like the LookVector. Its magnitude(length) is almost exactly one
-- (just little inaccuracy)
local dir = Vector3.new(newX, newY, newZ)
-- setting the velocity of BV
BV.Velocity = dir*SPEED
This can be achieved more easily with CFrame multiplication, but I thought that it might be more efficient when using the code above. I’m not sure about the efficiency, though, and the performance impact will be extremely small even if there is one. Anyways, here’s an alternative with CFrame multiplication. It’s a more readable option so it might be better to use it, because an extremely small possible efficiency bonus might not be worth sacrifising readability.
local VELOCITY = 300
local ANGLE_IN_DEGREES = 40
local dir = (player.Character.HumanoidRootPart.CFrame*CFrame.Angles(math.rad(ANGLE_IN_DEGREES), 0, 0)).LookVector
BV.Velocity = dir*SPEED