Ok, so, I’m making a sort-of top down camera, and I’m trying to use raycasts to detect when a player is hidden behind an object, so I can highlight them so they’re aware of their position.
But, for whatever reason this raycast always returns nil
, despite there being a very obvious break in the line of sight of the player.
local RayBlacklist = RaycastParams.new()
RayBlacklist.FilterDescendantsInstances = {Character}
RayBlacklist.FilterType = Enum.RaycastFilterType.Blacklist
local CollisionRay = workspace:Raycast(Camera.CFrame.Position, Character.HumanoidRootPart.Position, RayBlacklist)
Visualiser:Destroy()
Visualiser = Instance.new("Part", workspace)
Visualiser.CFrame = CFrame.new(CollisionRay.Position,CollisionRay.Position)
Visualiser.Anchored = true
The “Visualiser” part is a debug part that I tried to make to diagnose why it wouldn’t execute a print()
when the ray fired. But, since it’s not returning anything, that didn’t work…