Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ray-casting Blacklist Not Working?

Asked by 3 years ago
Edited 3 years ago

I want it to print what the camera is looking at but it will only print a part of the character (note: I blacklisted the character) or "Ray Hit Nothing"

Here is the code:

camera = workspace.CurrentCamera
player = game.Players.LocalPlayer
character = player.Character

local function Shoot(start, direction)
    local rayParams = RaycastParams.new()
    rayParams.FilterType = Enum.RaycastFilterType.Blacklist
    rayParams.FilterDescendantsInstances = {character}
    local ray = workspace:Raycast(start, direction, rayParams)
    if ray then
        print(ray.Instance)
    else
        print("Ray Hit Nothing")
    end
end

while true do
    Shoot(camera.CFrame.Position, camera.CFrame.LookVector)
    wait(1)
end

please help :( thanks

0
Also I am looking at a object when I run this CubicleHead -3 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

The direction has a length of one, it should work if you multiply it by some larger number e.g.

Shoot(camera.CFrame.Position, camera.CFrame.LookVector * 1e4)

(1e4 is short for 10000 btw)

Ad

Answer this question