How do I find if an instance is to the left side of my car

I want to find if a part front of my car is to the left or right to my car
But it says right all the time

As you see an obstactle is at the left, but it says right in the screen

Here is my script:

local debris = game:GetService("Debris")
while wait(0.5) do
    for i,v in pairs(workspace:GetPartsInPart(script.Parent.Parent.Part,OverlapParams.new())) do
        if v:IsA("Part") and v.Name ~= "Baseplate" and v.Name ~= "ScreenPart" and v.Name ~= "BasePart" then
            print(v.Name)
            local clone = game.ReplicatedStorage.TextLabel:Clone()
            clone.Parent = script.Parent.SurfaceGui
            local magnitude = script.Parent.Parent.BasePart.Position.Z - v.Position.Z
            local isright = false
            if v.Position.X < script.Parent.Parent.BasePart.Position.X then
                isright = true
            end
            if isright == true then
                clone.Position = UDim2.new(0,0,0,0)
            else
                clone.Position = UDim2.new(0.8,0,0,0)
            end
            debris:AddItem(clone,0.5)
            clone.Position = UDim2.new(clone.Position.X,0,math.clamp(magnitude/20,0,1),0)
        end
    end
end

How do I make it detect if the obstacle is at right side or left side for the car?

Put the car in object (relative) space to the instance you’re checking before working with any of the axis coordinates. Without doing that, you’re working in world space.

1 Like

Oh ok, but how do I check if its left or right, some random cframe is coming in object space