Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Ray-casting Blacklist Not Working?

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

1 comment

0

Also I am looking at a object when I run this

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.