How would I detect if a player is inside a certain room? - without using magnitude, as magnitude has a "circular" type of detection, I tried using magnitude but it wouldn't count the player inside the room if the player was in a corner. What do I use to accomplish this?
Detect if player is in a certain room?
1 answer
Hello. I will be helping you, please read everything carefully. This will be like a tutorial.
First I have questions my self.
Does you game only have 1 building? 1 Room?
Anyway, how I would do this is insert a script to ServerScriptService. Type this code in:
game.Players.PlayerAdded:connect(function(player)
local PlayerStatus = Instance.new("Folder")
PlayerStatus.Parent = player
PlayerStatus.Name = "Storage"
local InRoom = Instance.new("BoolValue")
InRoom.Parent = PlayerStatus
InRoom.Name = "InRoom"
InRoom.Value = false
end)
Now I would add a part, make sure part settings are Anchored, can collide false and transparency = 1
Add Touch Function
local part = script.Parent
part.Touched:connect(function(Hit)
if Hit.Parent:WaitForChild("Storage").InRoom = false then
-- Do what you need to do
end
end)
Sorry this is kinda rushed because I had to leave (or else a made mob would have killed me)
Try it out and make sure you change the InRoom value. If InRoom value is true then it means the player is touching the part.
Make sure to accept answer and Upvote if helped.
If you have any questions or comments or anything to say comment and I will get back to you.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
create a block and detect when the player interacts with it, (idk if it works with can collide off though)
I tried using .Touched and .TouchEnded, but it would only be triggered when the is player moving and would stop once the player has stopped moving. I can't just use .Touched as I need to detect when the player leaves the room as well.
I haven't experimented a whole lot with this API, but you should read up on Region3. It looks like the API does what you want to do.
http://wiki.roblox.com/index.php?title=API:Region3
Thank you!
I would edit your question title and add [Answered] so other users don't attempt to answer :)