Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make so that players get points every second? But only when they are in a specific area?

1 answer

Hi I may have an answer for your question. You should use FindPartsInRegion3. In order to do this, you must imagine a square for your area. You must pick the top left corner of your square and find its position and you must pick the bottom right of your square and find its position.

this is the top left corner of your square-     .  --------------------------------------------|
                                                                     |                                                       |  
                                                                     |                                                       |
                                                                     |                                                       |  
                                                                     |                                                       | 
                                                                     |                                                       |
                                                                     |                                                        |  
                                                                     |                                                        | 
                                                                      -----------------------------------------------
                                                  this is the bottom right corner of your square-     .

As illustrated above roblox can make out a square with just 2 points!

lets say out top left corner was 0,0,0 lets say our top right corner was 5,5,5

heres a code:

local Top_left = Vector3.new(0,0,0)
local Top_right = Vector3.new(5,5,5)
local Region = Region3.new(Top_left,Top_right)

for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region)) do
  if Part:FindFirstChild == ('Humanoid') then
    print('Someone is here!')
  else
   print('No one is in my area yay social distancing!')
end

You dont need to create a part yourself as far as I know region3.new creates a part automatically!

Hope this was helpful!

Any Questions? just ask!

EDIT: Sorry for the messy square diagram you can make a square out of 2 points on a piece of paper if you want!

2 comments

0

Have you actually tested it?

0

doing (if Part:FindFirstChild == ('Humanoid') then) will error and also Part will be a BasePart of the Character so you should do it like this (if Part.Parent:FindFirstChild('Humanoid') then) . When it returns an instance that means it's true otherwise, false

This discussion is preserved as it was. New answers, comments, and votes are closed.