I’m making a mystery/horror type of game and I’m using RayCasting to detect where the player is looking towards so I can change the way the room looks when the player turns back. I have the following code:
wait(2)
local character = game.Players.LocalPlayer.Character
local head = character.Head.Position
local MyRayCast = Ray.new(head, Vector3.new(0,0,20))
while wait(1) do
local part = game.Workspace:FindPartOnRayWithIgnoreList(MyRayCast, {head, character})
if part then
if part.Name == "Wall1" then
print("yes")
end
end
end
Heres what I have now after the changes you told me to make:
wait(2)
local character = game.Players.LocalPlayer.Character
local head = character.Head
local MyRayCast = Ray.new(head, Vector3.new(0,0,20))
while wait(1) do
local part = game.Workspace:FindPartOnRayWithIgnoreList(MyRayCast, {head.Position, character})
if part then
if part.Name == "Wall1" then
print("yes")
end
end
end