Floor Blacklisting (Edge Detection)

What I wanted to do was a Spider-Man web zipping system. After preparing half a script ready, I ran into this jarring problem that comes and goes like an undead fly. The Raycasting would detect the part/floor the player was currently on.

I’ve scrolled through several posts like this one: How do you detect the floor the humanoid is standing on? - #3 by bluebxrrybot
Despite the floor/part being inserted into the Blacklist table, it would continue to detect said part.

Here is the script currently…

local RunService = game:GetService("RunService")

local Event = game.ReplicatedStorage:WaitForChild("ZipEvent")

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local RootPart = Character:WaitForChild("HumanoidRootPart")

local EdgeIndicator_Part = Instance.new("Part")
EdgeIndicator_Part.Color = Color3.new(1, 1, 1)
EdgeIndicator_Part.Material = Enum.Material.Neon
EdgeIndicator_Part.Transparency = 1
EdgeIndicator_Part.Name = "Edge_Indicator"
EdgeIndicator_Part.Parent = workspace
EdgeIndicator_Part.Size = Vector3.new(1, 1, 1)
EdgeIndicator_Part.CanCollide = false
EdgeIndicator_Part.Anchored = true

local FloorIndicator_Part = Instance.new("Part")
FloorIndicator_Part.Color = Color3.new(1, 1, 1)
FloorIndicator_Part.Material = Enum.Material.Neon
FloorIndicator_Part.Transparency = 1
FloorIndicator_Part.Name = "FloorIndicator_Part"
FloorIndicator_Part.Parent = workspace
FloorIndicator_Part.Size = Vector3.new(1, 1, 1)
FloorIndicator_Part.CanCollide = false
FloorIndicator_Part.Anchored = true


local BillboardGui = Instance.new("BillboardGui", EdgeIndicator_Part)
BillboardGui.AlwaysOnTop = true
BillboardGui.Size = UDim2.new(2, 0, 2, 0)

local ImageLabel = Instance.new("ImageLabel", BillboardGui)
ImageLabel.BackgroundTransparency = 1
ImageLabel.Size = UDim2.new(1, 0, 1, 0)
ImageLabel.Image = "rbxassetid://13127171180"

local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Blacklist
RaycastParameters.FilterDescendantsInstances = {Character, EdgeIndicator_Part, FloorIndicator_Part}
RaycastParameters.IgnoreWater = true

RunService.RenderStepped:Connect(function()
	--Floor Detection
	FloorIndicator_Part.CFrame = RootPart.CFrame + RootPart.CFrame.UpVector * (-3 - Humanoid.HipHeight)
	local Connection = FloorIndicator_Part.Touched:Connect(function() end)
	local Parts = {
		unpack(FloorIndicator_Part:GetTouchingParts())
	}
	for i, floor in Parts do
		if floor:IsA("Part") and not floor:IsA("MeshPart") then
			table.insert(RaycastParameters.FilterDescendantsInstances, floor)
		end
	end
	
	--Edge Detection
	local EdgeOrigin, EdgeDirection = RootPart.Position, Camera.CFrame.LookVector * 300
	local EdgeRaycast = workspace:Raycast(EdgeOrigin, EdgeDirection, RaycastParameters)
	if EdgeRaycast then
		local Part = EdgeRaycast.Instance
		if Part:IsA("Part") and not Part:IsA("MeshPart") then
			if Part.Size.Y >= 100 then
				local Part = EdgeRaycast.Instance
				local Position = Vector3.new(EdgeRaycast.Position.X, Part.Position.Y + Part.Size.Y/2, EdgeRaycast.Position.Z )

				EdgeIndicator_Part.Position = Position
			end
		end
	end
end)

I remember testing something in the past related to the Filter table, and my conclusion was that the only way to update the filter it is to reassign the table to that property, so you can’t use table.insert or directly modify the filter table. That could be the problem, but once again, this was a while back so things may have changed. But just something to keep in mind.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.