Is there an easy way to stop a player from walking off the edge of a part?
I am currently using an invisible wall to do this. Nice and easy. My problem is I’ve got lots of these walls, and I want to let the players shoot through them (ie allowed to shoot off roof top, but not allowed to walk off rooftop), but my raycast blacklist is getting quite large in size. I’m hoping for something more performant.
I’ve tried making the walls low enough to shoot over without the blacklist, but still high enough to stop people walking/jumping over them, but it doesn’t work well enough.
NB: any solution must work with click-to-move pathing.
My gut says the invis wall is the best solution, but I thought I’d ask anyway.
Thanks all
You could use Collision groups to make the player not be able to walk past the barrier but letting the bullet go past,
To do this you’ll need to create another CollisionGroup and then when the bullet is shot assign the bullets CollisionGroupId to 1 and for the player when he joins his bodyparts should be already assigned to 0. In the CollisionGroup menu you wanna set the new collision group to not have a checkmark under the default
If you would like to make the blacklist smaller, I’d suggest putting all the invisible walls in one folder and setting the blacklist to thatfolder:GetChildren(). Nice and clean. You can also do it using CollectionService, but that’s a bit more complicated.
Try adding a tiny border on the floor around the map, and calling it MapBorder (or whatever you want, just easy for this script)
local border = game.Workspace.MapBorder
if border.Touched then
--add a teleport to a few paces away, and they should never be able to walk off the edge
end