Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I check if I am facing another player?

I want to push a Character back, similar to Force Push, but only if I am facing them, how do I do this?

local ray = Ray.new(Character.Head.Position,(Mouse.Hit.p -Character.Head.CFrame.lookVector).unit * 100) --Distance

-- how to check if the player is facing another character?

local part, position = workspace:FindPartOnRay(ray, Player.Character,false,true)
local distance = (Character.Head.CFrame.p - position).magnitude
	if distance < 50 then --if they're closeer that 50 studs push them
		Torso.Velocity = CharTorso.CFrame.lookVector * 100
	end

1 answer

val = ((part.Position-torso.Position).unit+torso.CFrame.lookVector).magnitude

If val = 2 -- Then torso is facing part directly.
if val = 0 -- Torso is facing completely away.

This is really simple, could be better.

1 comment

0

Hey can you accept this answer or something.

This discussion is preserved as it was. New answers, comments, and votes are closed.