Alternatives to raycasting?

I’d like to know any alternatives to raycasting in scripts.
Reason?
Well, the primary reason is well
Lag!
It works fine the first few minutes. But then things get messy when it is looped.
The raycast slows the server to the point of even the beefiest computers crashing.

So; any smoother alternatives?

Things I tried (that didnt work):
Doing raycasts on the client side
Increasing delay between raycasts (This worked, but it broke the script.)

1 Like

Depends on what else you are doing with the ray and the type of ray.

If you are using while wait() do loop, that can indeed happen.

I’m using heartbeat inside a while true do loop.

Now it depinds on the way you are using it, are there any events connected to a function inside that loop? What do you do in that loop?

yea no wonder you got lag. Every time it runs make it print(“RayCreated”) and see how many times its printed. You will see why.

I’m using it for a fake character script. I’m doing this so it doesnt go into the ground, while also being able to go through walls.

I am aware HumanoidState exists, but there is no humanoid here. All parts are anchored too.

if its only for that just change the collision id. theres not really any need to loop rays for this. So once the char hits the wall it can create a platform with the same collision id and walk right through. this means that while you arent waling through walls it will appear normal.

:man_facepalming: I forgot a thing!
I also want it to be able to STAND on top of parts that are not collidable.

I would recommend the FastCast Module I use this alot. However it is for projectiles but you could set the speed of the bullet to make it super fast.

I think I may have found the solution:
Cease the raycasts if wait() goes above a value
I’m going to mark this as the solution.