Basically, I am trying to detect, if someone is near me and if im facing them. The script is written down below, but I get an error when i press the R key, which is: ** Parent is not a valid member of Ray** on this line
if theRay.Parent:FindFirstChild("HumanoidRootPart") then
I don't understand what am I doing wrong, anyone could help, first time using ray casting
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local Character = player.Character
local theRay = Ray.new(Character.HumanoidRootPart.Position, Character.HumanoidRootPart.CFrame.LookVector * 10)
if theRay.Parent:FindFirstChild("HumanoidRootPart") then
theRay.Parent.Humanoid:TakeDamage(20)
end
end)

2 comments
Parent is not a valid member of Ray
hmm thats weird