Maybe it’s because you’re attempting to use a range with a negative number and a positive number.
If this returned a negative number, it would go down on the y-axis leading it to be under the baseplate. It wouldn’t even intersect the baseplate.
Do you need it to be a negative number? Or are you just trying to get a range in between? If you’re not, you can simple use math.abs (get the absolute value of the number)
-- its making it go in a really wierd position
local cast = Raycast(RayPos + Vector3.new(0,50,0),RayPos +Vector3.new(0,-50,0),{})
-- this is what it should have been
local cast = Raycast(RayPos + Vector3.new(0,50,0),Vector3.new(0,-50,0),{})
Hm well from the way I’ve interpreted it, I’d probably just check if the enemy is in the line of sight of a nearby player (you’d either retrieve that from a raycast or using a Spatial Queryor manually checking the distance of each player)
If they are, then find a nearby object.
If the guy can crouch, basically do the equation to get the height (in Vector3 form) and see if any nearby objects is less than or equal to that value (you can use math.clamp for this)
This guy thinks he can walk up walls. (he’s trying to Path find up the hill.)
With what you just said do you think I would have to put a point behind all hidable objects? then he would see which one is closest, provides best cover?
Maybe you could come up with a way to get the longest side of the part and add something depending on what you get from that. Is that even possible? I’m not sure
Or you could just get the LookVector or the part and determine what to do from there.