How to detect if player isnt facing wall anymore?

Hi, so I am trying to accomplish a feature where if you’re near a wall it plays a animation like this.


Now the thing is I have already completed the first part by firing a raycast.

	local WallRay = Ray.new(HRP.Position, HRP.CFrame.LookVector * 2)
	local Wall, HPS, Normal, Material = workspace:FindPartOnRay(WallRay, Character)
	if Wall and Wall:GetAttribute("Wall") then
		HandAnim:Play()
	end

The issue here is that the hand animation keeps playing even after you’re not facing the wall, and I am very confused on how I would detect if the player is not facing a wall anymore. If anybody can help me with this it would be greatly appreciated.

1 Like

you make if not Touched it play the animation if it touched the part it play

Once the player faces a wall, store it in a variable and create a loop to fire a ray. Check if the part the ray hits is the wall, if it is not the wall/hits nothing, then the player is no longer facing the wall.

Also Ray is outdated, use WorldRoot:Raycast()

for more information see this link

1 Like