The project im currently working on requires a tool that does a Raycast to check the current block in front of the player however when I set the filter to blacklist, Its like the ray is completely ignoring the parameters I assigned. So far ive tried assigning just the player in hopes that it will blacklist the players children and the tools children, and ive also added the tool to that list to be more explicit, however the issue still persists.
Shovel.lua
local ContextActionService = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Handle = script.Parent.Handle
local Tool = script.Parent
local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Hits = 0
local startTick = tick()
local active = false
local hitting = false
local ShovelRaycastParams = RaycastParams.new()
ShovelRaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
ShovelRaycastParams.FilterDescendantsInstances = {
Tool,
Player.Character,
}
Tool.Equipped:Connect(function()
active = true
end)
Tool.Unequipped:Connect(function()
active = false
end)
ContextActionService:BindAction("Hit", function(name, state)
if state == Enum.UserInputState.Begin then
hitting = true
elseif state == Enum.UserInputState.End then
hitting = false
Hits = 0
end
end, false, Enum.UserInputType.MouseButton1)
RunService.RenderStepped:Connect(function()
local HitResult = workspace:Raycast(Camera.CFrame.Position, Camera.CFrame.LookVector * 7, ShovelRaycastParams)
if HitResult then
print(HitResult.Instance.Parent)
end
if active then
if hitting then
if tick() - startTick > Handle.HitSpeed.Value then
Hits += 1
startTick = tick()
end
end
end
end)