Hello, I'm recently new to using 'Dot product'. I'm trying to make it so that when you see a certain player, this will print "A". However, It isn't doing this, It is working sometimes but its all depending on camera position for some reason? If anyone can help that'd be super great, my code is below. Thank you, by the way - Vector returns the other players CurrentCamera position.
self.BeingViewed = function(subject)
local _2 = Players:GetChildren();
for _3 = 1, #_2 do
local player = _2[_3];
if player:IsA("Player") then
local Subject = subject;
local DirectSubject = player;
if Subject and DirectSubject and DirectSubject:IsA("Player") and Subject.UserId ~= DirectSubject.UserId then
if EventMapper then
local ECameraVector = EventMapper:FindFirstChild("CameraVector");
if ECameraVector and ECameraVector:IsA("RemoteFunction") then
local Vector = ECameraVector:InvokeServer(DirectSubject);
local Camera = Workspace.CurrentCamera;
if Vector and Camera then
local A = Vector.Unit;
local B = Camera.CFrame.Position.Unit;
if A and B then
if A:Dot(B) < 0 then
print("A");
end;
end;
end;
end;
end;
end;
end;
end;
