CODE:
region = Region3.new(Vector3.new(-13.375, 1.85, 6.58),Vector3.new(7.63, 3.7, 5.12)) while true do wait() for i,v in pairs(game.Workspace:FindPartsInRegion3(region,nil,1000)) do if v:FindFirstChild("Humanoid") then ---do crap here end end end
I'm having trouble finding what I need. ALL I wanna do is if a player is in this region, do this. AND if a player leaves, stop this.
To find a player, you need to use :GetPlayerFromCharacter()
, because :FindPartsInRegion3()
will be detecting a part, which will be a child of the player's character.
In addition to your code, then...
region = Region3.new(Vector3.new(-13.375, 1.85, 6.58),Vector3.new(7.63, 3.7, 5.12)) while true do wait(.1) --you probably don't need a loop iterating so quickly for i,v in pairs(game.Workspace:FindPartsInRegion3(region,nil,1000)) do if v.Parent:FindFirstChild("Humanoid") then --determine if it's player-like local Player = game:GetService("Players"):GetPlayerFromCharacter(v.Parent) if Player then --confirm it is a real player --do code else --do code for player leaving end end end end