I will mark this as a solution
So what I did is go to the Raycast part
create blacklist for accessories:
- make a list (
blacklist
) excluding the player’s character but including all accessories and their parts
local blacklist = {self.character} for _, acc in pairs(workspace:GetDescendants()) do if acc:IsA("Accessory") then if acc:FindFirstChild("Handle") then table.insert(blacklist, acc.Handle) else for _, part in pairs(acc:GetDescendants()) do table.insert(blacklist, part) end end end end
set up raycast parameters:
- configure raycast parameters to ignore water, exclude items in the blacklist, and set other necessary properties
perform raycast:
- cast a ray with the custom parameters. if the ray hits something, print the position; otherwise, return a distant point
local hitResult = workspace:Raycast(ray.Origin, ray.Direction * 1000, castParams) if hitResult then print("hit position:", hitResult.Position) return hitResult.Position else print("no hit, returning a point far along the ray.") return ray.Origin + ray.Direction * 1000 end