Why is my script ignoring the raycast?

It seems to ignore the not hit:IsDescendantOf(workspace.HappyHome)

Error: Humanoid is not a valid member of Model “Workspace.HappyHome.Home.Model.Roof”

Code:

if not hit:IsDescendantOf(workspace.HappyHome) and not hit.Parent:IsA("Accessory") or not hit:IsA("Accessory") or not hit.Name == "Head" then
			local humanoid = hit.Parent.Humanoid
end
2 Likes

Use “and” for your entire statement dont use “or”

1 Like

ServerScriptService.Script:70: attempt to index nil with ‘IsA’

if hit and hit.Parent and not hit:IsDescendantOf(workspace.HappyHome) and ...

So on

You should first check for the Hit.Parent's Humanoid to make sure that there really is a valid one

if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(workspace.HappyHome) and not hit.Parent:IsA("Accessory") then
    local Humanoid = hit.Parent.Humanoid
end
1 Like