Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Detect if player is in a certain room?

Asked by 7 years ago

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?

0
create a block and detect when the player interacts with it, (idk if it works with can collide off though) abnotaddable 920 — 7y
0
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. User#2146 0 — 7y
0
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. Troidit 253 — 7y
View all comments (2 more)
0
Thank you! User#2146 0 — 7y
0
I would edit your question title and add [Answered] so other users don't attempt to answer :) Troidit 253 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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.

Ad

Answer this question