Checking players current room

Basically, the player has a house. Inside that house I have a folder called ‘Rooms’ and inside that parts named ‘01’, ‘02’, etc. These are sized to each room. And I want to basically be able to check what room the player is currently in when they press a button

for _, v in pairs(Page:GetChildren()) do
	if v:IsA('ImageButton') then
		v.Activated:Connect(function()
			print('You are in room' ..  currentRoom)
		end)
	end
end

However I am not sure how to go about this effectively? And if using Region3 would be compramised, as I’m doing this via client scripts, and the each players house has their own name, and I basically want to send the players current room to the server, so it changes that rooms floor/wall design

Try calling GetTouchingParts() on the part sized to the room. Check all of the parts that the command returns and if its a member of the player’s character then the player is in the room

Isn’t showing the part in the output?


Output
[Head NinjoOnline]
[LowerTorso NinjoOnline]
[UpperTorso NinjoOnline]

for _, touching in pairs(Character.PrimaryPart:GetTouchingParts()) do
	print(touching, touching.Parent)
end

Can see in the SS that my character is well inside the part

Sounds like you might want to take advantage of this.

3 Likes

I think it would be simpler to call GetTouchingParts on the part in the room instead of the character and then check if one of the player’s members is in the list