Hello, I am trying to detect when a player is moving into a wall then I want to print("1"). Please note I’m fairly new to raycasting so I am confused on how to work it.
Here is my code;
local rayDirection = Vector3.new(0.2, 0, 0)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character, character.Head}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
runService.RenderStepped:Connect(function()
if MOVEMENT_FUNCTIONS.CheckMovement() then
local rayOrgin = character.Head.CFrame.LookVector
local raycastResult = workspace:Raycast(rayOrgin, rayOrgin + rayDirection, raycastParams)
local result2 = rayOrgin + rayDirection
print(result2)
if raycastResult then
print("1")
end
end
end)
How could I do this? Because if I do add a check e.g humanoid.MoveDirection.X > 0 then when I move left it will always not return true if I’m hitting the wall or not.