I’m creating a ray casting delete system which when the player presses X it detects a block in front of you, so that it can then delete that block. The only problem is that the ray goes through this block detecting other blocks which I don’t want it to delete. Is there a way I could make it so when the ray fires it stops after hitting the first brick, or so when the ray hits it deletes the first block it hits and then leaves the others. I need the parts to be the same name so I have not used ignoreList.
local mouseRay = mouse.UnitRay
local last
local ignoreList = {game.Workspace}
local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 50)
local hit, position = workspace:FindPartOnRay(castRay)
hit:Destroy()
What about using {game.Workspace:GetChildren} ?
I should have mentioned this but the two parts are identical clones of each other so they have the same parent, same everything. So that would ignore both.
Depending on how your block system was created, you could opt to use FindPartOnRayWithWhiteList since it seems like you’re only concerned with a specific set of parts over all others and you can make said white list your blocks parts container. If you don’t have a container, the block creation code can use CollectionService to tag blocks and then you can pass the returned array from GetTagged on the block tag as the white list.
1 Like
Why he whould add a table in a table? It only will error
1 Like
I am beginner to rays, so I dont really know what Im doing.