Raycast still triggers through walls?

Hello,
ironically, i recently just got help on this subject. It ended up working but for some reason still triggers through walls.

this is my code (the whole thing lol):

local camera = workspace.CurrentCamera
local mouse = game.Players.LocalPlayer:GetMouse()

local p = game.Players.LocalPlayer

local c = p.Character or p.CharacterAdded:Wait()


local VisCheck = function(Obj)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.FilterDescendantsInstances = {game.Players.LocalPlayer.Character}
	raycastParams.IgnoreWater = true
	local raycastResult = workspace:Raycast(camera.CFrame.Position, CFrame.new(camera.CFrame.Position,Obj.Position).LookVector*5000, raycastParams)
	if raycastResult ~= nil then
		if raycastResult.Instance:IsDescendantOf(Obj.Parent) then
			if Obj.Parent.Humanoid.Health > 0 then
				return true
			end
		else
			return false
		end
	end
	return false
end

local StartUITrack = function(Obj)
	local worldPos = Obj.Position
	local pos, isOnScreen = camera:WorldToScreenPoint(worldPos)
	local fixedposx = pos.x
	local fixedposy = pos.y
	local IsInLib,num = false, nil

	if isOnScreen then
		if VisCheck(Obj)== true then
			return true
		end
	else 

	end

	return false
end







while wait() do
	
	local mag;
	
	local range = game.Lighting.FogEnd - 2;

	local cansee = true
	
	local DummyHead = workspace.Slenderman["Meshes/torso (3)"]
	
	coroutine.wrap(function()
		while wait() do
			mag = (c.Torso.Position - DummyHead.Position).magnitude;
		end
	end)()
	
	local WG = workspace.Slenderman
	
	coroutine.wrap(function()
		while wait() do
			local Position, CanSee = camera:WorldToScreenPoint(workspace.Slenderman["Meshes/torso (3)"].Position)
			if CanSee and mag <= range and cansee then 

				local StaticMain = script.Parent.StaticGUI
				local Static1 = StaticMain.Static1
				local StaticSound = script.StaticSound

				StaticSound.Playing = true
				StaticSound.Looped = true

				StaticSound.Volume = 1 /mag * 2

				StaticMain.Enabled = true
				Static1.Visible = true
				Static1.ImageTransparency = 0.50 * mag / 8.55
				wait(0.1)
				Static1.ImageTransparency = 0.75 * mag / 8.55
				wait(0.1)
				Static1.ImageTransparency = 0.25 * mag / 8.55
				wait(0.1)
				Static1.ImageTransparency = 0.9 * mag  / 8.55
				wait(0.1)

			else

				local StaticMain = script.Parent.StaticGUI
				local Static1 = StaticMain.Static1
				local StaticSound = script.StaticSound

				StaticMain.Enabled = false
				StaticSound.Playing = false

			end;
		end;
	end)()

	local IsSeen = StartUITrack(WG["Meshes/thehead"])
	if IsSeen == true then

	end

end

any help is greatly appreciated, thank you in advance

1 Like

which bit triggers through walls?

maybe i didn’t clarify this well

what i mean is, the static GUI can still trigger even when slender is behind a wall

Maybe you could actually see if it goes through walls by putting a part where the raycast hits, I have to go now