Your question is simple on the surface, but actually quite complex. All we’re given is the initial speed, our starting position, and the position we need to hit in the future. All of this is with parabolic motion, of course (the other guy thought you were shooting in a straight line, which will always make the projectile fall short of its target).
Even though I’ve taken a few physics and mathematics courses myself, I still ended up spending a bunch of time on the problem, and eventually looked up a YouTube video to give me some assistance:
You can watch to get a better understanding of how the equation I’m about to give you was derived, but a lot of it is probably going to go over your head (happened to me a little bit too).
Anyways, here you go:
local dh = endPos.Y - startPos.Y
local dx = ((endPos - startPos) * Vector3.new(1, 0, 1)).Magnitude
local XRotation = (math.acos(((g * (dx^2) / (projVel^2)) - dh) / math.sqrt((dh^2) + (dx^2))) + math.atan(dx/dh))/2
To tell you the truth, I barely understand this mess. If you want, I could probably help you get the YRotation as well. That’d be a lot simpler.