So I'm trying to figure out how to check if a player is in a specific area in the map, but I don't know what method to use. Basically I want it so while the player is in an area a value is set in their player to true. This would then communicate with other scripts to make an effect.
This is pretty simple. You can use Region3.new()
. That is one method. You can put a Part
in the area that you want the player to be in. Region3
This is the script
local part = -- Put the part path here. local value = -- Put the value name here(In a string, else it will not work), Has to be in the player and not in one of the children of the player function CreateRegion3(Part) return Region3.new(Part.Position-(Part.Size/2), Part.Position+(Part.Size/2)) end function FindPlayerInRegion3FromPart(PartToFindPlayerIn) local partForRegion = CreateRegion3(PartToFindPlayerIn) local playersInRegion3 = workspace:FindPartsInRegion3(partForRegion, nil, math.huge) for i, v in pairs(playersInRegion3) do local player = game.Players:GetPlayerFromCharacter(v.Parent) if player ~= nil then if player:FindFirstChild(value) then player[value].Value = true end end return player end end while wait(0.5) do FindPlayerInRegion3FromPart(PartToFindPlayerIn) end
If this does not work, please comment and I will try to fix it. After this you can do the communicating with scripts for the effect.