This will not work and will give an error.
You can just do this instead:
raycastParams.FilterDescendantsInstances = {script.Parent.Parent}
This will not work and will give an error.
You can just do this instead:
raycastParams.FilterDescendantsInstances = {script.Parent.Parent}
Oh shoot you’re right great catch.
Another thing you can do is
local filterLiist = {} -- assuming you're excluding more instances than just the character
if char then
table.insert(filterList, char)
raycastParams.FilterDescendantsInstances = filterList
end
If you do this filterList I’d recommend to cleanup instances from the filter list if they’ve been destroyed/removed from game
OOO let me just try this rq one sec…
how would you do that from a serverscript?
is it smart to do it from a serverscript (exploit security)
or why? not?
how does raycast filter? by cantouch? or by canquery???
So whenever you’re raycasting if you add something to the FilterDescendantsList and you have a RaycastFilterType it will either only find a result with or without what’s in the FilterDescendantsList.
If you’re trying to raycast to a part with CanQuery set to false it won’t find it because it can’t query that part.
In addition, you aren’t required to have a RaycastFilter it’s just incase you want to ONLY include certain instances, or ignore them
oh. does it lag if i cast like 10 raycasts every renderstep?
also can i do infinite range?
It shouldn’t lag to be honest there’s games that do tons of raycast per frame such as FPS games. Setting the distance super high might cost more in performance though I believe.
OK: mind having a look at my finished script? i might have done some stupid unnecessar stuff
Raycasting is normally filtered by CanQuery
, although RaycastParams has a .RespectCanCollide
property which allows it to be filtered by CanCollide
instead.
You should never need more than 1 raycast in the same direction every frame.