local posthree = {}
posthree.X = 2
posthree.Y = 0
posthree.Z = 0

local rthree = {}
rthree.X = 0
rthree.Y = 0
rthree.Z = 0

local x3 = posthree.X
local y3 = posthree.Y
local z3 = posthree.Z
local rx3 = rtree.X
local ry3 = rtree.Y
local rz3 = rtree.Z

local x2 = ((math.cos(math.pi(rx3/180))*x3)  +  (math.sin(math.pi(ry3/180))*x3)  +  (math.sin(math.pi(rz3/180))*x3))

So apperently using math.pi you must use a sign before or after it


local x2 = ((math.cos(math.pi*((rx3/180))*x3)  +  (math.sin(math.pi*(ry3/180))*x3)  +  (math.sin(math.pi*(rz3/180))*x3))