I am making a ray cast because hit-detection is way too unreliable, but the ray cast I create cannot detect the ball I made (the ball has collision groups to only be able to touch the ground and also is network owner to the player but I don’t think those are the errors). Below is the code I’m using to find the ball (it detects everything else)
local raycastParams = RaycastParams.new()
local raycastResult = workspace:Raycast(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*100, raycastParams)
if raycastResult then
local currentPart = raycastResult.Instance
print(currentPart)
end
Make sure the CollisionGroup property of RaycastParams is set to the correct collision group.
If the ball is not a “Part” (ex: “MeshPart”, “UnionOperation”, etc) then check that the CollisionFidelity is set correctly
Make sure your testing conditions are right (With the example code, it would be shooting a ray in front of the player’s character) and the ball’s network correctly exists on the client/server the code is being run from.
If none of these fix your problem, I recommend just destroying & redoing the ball/code and then seeing if it works, because I see no logic/syntax problems in your provided code.
How large is the ball? If it was too small, then HumanoidRootPart may be too high for it to be detected. If the ball is not around the same size or bigger than the player, then the ray cast will not hit it.
It might be something you have already confirmed, but I am just telling you in case you have not.