Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I check if I am facing another player?

Asked by
Nidoxs 190
8 years ago
Edited 8 years ago

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

1local ray = Ray.new(Character.Head.Position,(Mouse.Hit.p -Character.Head.CFrame.lookVector).unit * 100) --Distance
2 
3-- how to check if the player is facing another character?
4 
5local part, position = workspace:FindPartOnRay(ray, Player.Character,false,true)
6local distance = (Character.Head.CFrame.p - position).magnitude
7    if distance < 50 then --if they're closeer that 50 studs push them
8        Torso.Velocity = CharTorso.CFrame.lookVector * 100
9    end

1 answer

Log in to vote
1
Answered by 8 years ago
1val = ((part.Position-torso.Position).unit+torso.CFrame.lookVector).magnitude
2 
3If val = 2 -- Then torso is facing part directly.
4if val = 0 -- Torso is facing completely away.

This is really simple, could be better.

0
Hey can you accept this answer or something. AdvancedCode 136 — 7y
Ad

Answer this question