I am trying to script a Firing Computer for my Artillery Model, to be displayed as a GUI. The goal of it is to display accurate information about how to hit a location that would be provided by the player by input. My current goal is to make it calculate the angle needed to hit it, but the calculations (in degrees) make the artillery overshoot the target.
local Artillery = script.Parent -- The Artillery Model.
local Missile = Artillery:WaitForChild("Missile") -- The projectile being fired.
local Base = Artillery:WaitForChild("Base") -- The bottom base of the artillery model.
local arctan, root, degrees = math.atan, math.sqrt, math.deg -- Shortened mathematic functions.
local MissileMass = Missile.Size.X * Missile.Size.Y * Missile.Size.Z -- The mass of the missile.
local v = 500 -- The velocity of the missile when it.
local v2 = v^2 -- The velocity of the missile, to the power of 2.
local v4 = v^4 -- The velocity of the missile, to the power of 4.
local g = (MissileMass * 196.2) -- The force of the gravity that is pulling down the missile.
local x = ((Base.Position - game.Workspace.Target.Position).magnitude) -- The Range of the Base from the Target.
local gx = g * x -- Gravity times Range.
local y = (Base.Position.Y - game.Workspace.Target.Position.Y) -- The height difference of the Base and Target.
local gx2 = g * (x ^ 2) -- G times X to the power of 2.
local yv2 = (2 * y * v2) -- 2 times Y times V to the power of 2.
local discriminant = root(v4 - (g * (gx2 + yv2))) -- The discriminant of the Quadratic Formula used in both roots.
local solution = arctan((v2 + discriminant) / gx) -- The Arc Tangent of one root of the Quadratic Formula equation.
local solution2 = arctan((v2 - discriminant) / gx) -- The Arc Tangent of the second root of the Quadratic Formula equation.
print(degrees(solution2))
print(degrees(solution))

5 comments
Edit your question, highlight all your code and click the blue Lua button, it'll put all your code in a code block so we can read it easier :)
Edited to add code block.
Thank you for the edit, I am new to scriptinghelpers though the website is very useful for situations like this.
Btw, you can get the mass of an object using :GetMass(). it will return the equation you did on line 6
At this point in time, Litozinnamon has already found out the answer with the advent of the Ballistics Tracker in the game Phantom Forces.