How do I find the relative orientation degree?
So basically I want to find the y orientation of the red axis relative to the green axis
Because I want to make a car that goes to the point
local backwheelspeed = 5
local frontwheelspeed = 25
local base = script.Parent.Base
local function grrfp(e)
local x,y,z = CFrame.new(base.Position-base.CFrame.LookVector.Unit/(base.Size.Z/2),e.Position):ToOrientation()
local er = game.ReplicatedStorage.Arrow:Clone()
er.Parent=workspace
er.CanCollide = false
er.Anchored=true
game:GetService("Debris"):AddItem(er,.05)
er.Position=base.Position-base.CFrame.LookVector.Unit/(base.Size.Z/2)
er.Orientation=Vector3.new(0,math.deg(y),0)
er.Size=Vector3.new(5,25,25)
er.Transparency=.3
er.Material=Enum.Material.Neon
er.BrickColor=BrickColor.Red()
local ers = game.ReplicatedStorage.Arrow:Clone()
ers.Parent=workspace
ers.CanCollide = false
ers.Anchored=true
game:GetService("Debris"):AddItem(ers,.05)
ers.Position=base.Position-base.CFrame.LookVector.Unit/(base.Size.Z/2)
ers.Orientation=Vector3.new(0,base.Orientation.Y+180,0)
ers.Size=Vector3.new(5,25,25)
ers.Transparency=.3
ers.Material=Enum.Material.Neon
ers.BrickColor=BrickColor.Green()
return math.deg(y)-(base.Orientation.Y+180)
end
while wait() do
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
if string.find(string.lower(v.Name),"bw") then
if string.sub(string.lower(v.Name),1,1)=="l" then
v.CylindricalConstraint.AngularVelocity=-backwheelspeed
elseif string.sub(string.lower(v.Name),1,1)=="r" then
v.CylindricalConstraint.AngularVelocity=backwheelspeed
end
elseif string.find(string.lower(v.Name),"fw") then
local ordif = grrfp(workspace.Ve)
if string.sub(string.lower(v.Name),1,1)=="l" then
v.CylindricalConstraint.AngularVelocity=-frontwheelspeed
v.Attachment.Orientation=Vector3.new(0,math.clamp(-ordif,-45,45),0)
elseif string.sub(string.lower(v.Name),1,1)=="r" then
v.CylindricalConstraint.AngularVelocity=frontwheelspeed
v.Attachment.Orientation=Vector3.new(0,math.clamp(ordif,-45,45),0)
end
end
end
end
end
Thanks in advance