Checking For Any Blockage Under a Part

In my game, each player has the ability to “upgrade” their base parts. The base parts, when they are un-upgraded, are a frame which players can easily walk under (and I want it to stay like that). When the base part is upgraded, the frame is filled with a part to prevent players from walking under it (intentional).

But here’s the catch; players have been abusing this and are upgrading their base parts when other players are under them, causing them to glitch and get flung off. So what i’m looking for is a way to detect any players under the base part and prevent any upgrading on it until the region under it is empty.

I already tried using Region3, but the base part can be rotated and Region3’s can’t be rotated.

Is there another method that i’m just missing out on? Any help would be appreciated.

Think Raycasting could be what you’re looking for.
Make a ray which goes directly under your player and find the first thing which is touched and check if it isn’t a player.

If it is a player, you can move that character away from blocking using :MoveTo()

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character.HumanoidRootPart
local newRay = Ray.new(HumanoidRootPart.CFrame.p, Vector3.new(0,-1,0).unit * 10)
local Hit = game:GetService("Workspace"):FindPartOnRay(newRay, Character) -- Second parameter is the ignore instance, in this case, you don't want the player to detect themselves as being the blockage

You can place a part under the base that will teleport players out when the base will be upgraded. If you will delay upgrading because of other players, you will now allow other players to abuse the base owner. The base owner should have complete control of his/her base, regardless of other player’s intrusion.

Actually @EgoMoose created a module that allows you to create rotated Region3. You can use that (I use it all the time). https://www.roblox.com/library/434885049/Rotated-region3

3 Likes

That’s just what I needed.

1 Like