I'm new to using Raycast and I'm trying to make it so the Raycast detects from the HumanoidRootPart, this is in StarterGui/PlayerGui. The issue with this is that it's only printing "near nothing!" even though I'm near blocks.

local Player = game.Players.LocalPlayer
local Character = game.Players.LocalPlayer.Character
local Humanoid = Character:WaitForChild('Humanoid')
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')

local origin = HumanoidRootPart.Position
local direction = HumanoidRootPart.CFrame.LookVector * 50

local raycastResult = workspace:Raycast(origin, direction)

if raycastResult then
	print("near something!")
else
	print("near nothing!")
end

Any help is much appreciated!

2 comments

0

Idk what’s wrong but make a part that points towards the direction coming from the origin and see if it’s pointing in the right direction

0

Found what was the issue, it doesn't update by itself. Instead I had to use while wait(0.1) do, or RenderStepped.