Currently making a door, trying to make it as accurate as possible to how a door would work irl. I tried using dot product, however, it’s very inaccurate, back side returns a negative number, same with front side.
Code:
local model = script.Parent.Parent.Parent;
local prompt = script.Parent;
local front = model:WaitForChild("front");
local back = model:WaitForChild("back");
local opened = false;
prompt.Triggered:Connect(function(player)
local direction = (player.Character:WaitForChild("HumanoidRootPart").Position - model.Parent:WaitForChild("Handle").Position);
if direction:Dot(model.Parent:WaitForChild("Handle").CFrame.LookVector) > 0 then
print('true');
else
print('false')
end;
end);