How do i get what parts are touching a part to verify them?

im working on a script that “tracks” what room you are in but i found some issues like if you somehow enter a room while in another room.
I had the idea of checking constantly what room your player is touching, how do i do that?

instad of touched signals is there one thats like CurrentlyTouching?

1 Like

Running every frame (from what I get from your description) is not ideal.

I recommend using spatial for example: workspace:GetBoundingBox() with the characters values or you could try to use ZonePlus a module made by ForeverDev which uses spatial queries and they are ready to be used without having the effort of building your own touch connections. All documentation and videos on how to use are in the post I linked up.

Hope this helps

what im doing right now is this:
every room has a box in it covering the whole room, when its touched it changes a string value in the player to say that rooms name.
Im not planning on running this every frame, more like every second just to insure and verify that the player is indeed in that room and hasnt glitched the code

Ok. could you share the code?

character limit

local Plrs = game:GetService("Players")

-- Adding PTS and Rooms --
Plrs.PlayerAdded:Connect(function(Plr)
	local PTS = Instance.new("Folder")
	PTS.Name = "PlayerTrackingService"
	PTS.Parent = Plr
	print("Added PTS To: "..Plr.Name)
	
	task.wait()
	
	local PTSR = Instance.new("StringValue")
	
	PTSR.Parent = PTS
	PTSR.Name = "CurrentRoom"
	PTSR.Value = nil
end)



-- Changing rooms --
local Rooms = game.Workspace:WaitForChild("RoomTracking"):GetChildren()

for _, V in Rooms do
	V.Touched:Connect(function(Plr)
		if Plr.Parent:FindFirstChild("Humanoid") then
			local PlrPlr = Plrs:FindFirstChild(Plr.Parent.Name)
			PlrPlr.PlayerTrackingService.CurrentRoom.Value = V.Name
		end
	end)
end

As I said you should try ZonePlus, it’s the best and more accurate way to detect any collisions inside your hitboxes.