I want to be able to check if a wall is infront of my player, the wall being a part within PlayersInterior.Build.InteriorElements and I use FindPartOnRayWithWhitelist so it’s only checking for parts within a certain folder (where the walls are stored) however, it always returns nil, no matter what way my player is facing
local CheckRay = Ray.new(Player.Character.HumanoidRootPart.CFrame.p, Vector3.new(0, 0, 5))
local part = workspace:FindPartOnRayWithWhitelist(CheckRay, {PlayersInterior.Build.InteriorElements})
print(part)
I’m pretty sure your answer is gonna be there, I read it and understood some of it and then found out that you can use it to your advantage.
You can edit the script found in that website to give you this ( not my script, I just derived this using the example, all credits go to @Eternalove_fan32 )
local Player = game.Players[PlayerName]
local HRP = Player.Character.HumanoidRootPart
local Lenght = 15
local Ray = Ray.new(HRP.Position, HRP.CFrame.LookVector*Lenght)
local Wall, HitPosition, Normal, Material = workspace:FindPartOnRay(Ray, Player.Character)
if Wall then -- If wall is in front of you
print("wall in front of you")
else -- if theres no wall
print("wall not in front of you")
end
edit: I tried the script on studio and it worked fine.
Probably a long shot but try this script out, maybe it might solve it? This is like my second time working with rays so I’m sorry if it doesn’t work.
local Player = game.Players[PlayerName]
local HRP = Player.Character.HumanoidRootPart
local Lenght = 15
local Ray = Ray.new(HRP.Position, HRP.CFrame.LookVector*Lenght)
local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {PlayersInterior.Build.InteriorElements})
if Wall then -- If wall is in front of you
print("wall in front of you")
else -- if theres no wall
print("wall not in front of you")
end