So I made a script that's supposed to tell the player in which they neighborhood they are after they exit the current one (basically like the city names that appear in gta games) but it doesn't work:
game.Players.LocalPlayer.CharacterAdded:Wait()
local player = game.Players.LocalPlayer
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("HumanoidRootPart")
local pos = hum.Position
local gui = player.PlayerGui.mainGUI
function isInRegion3(region, point)
local relative = (point - region.CFrame.p) / region.Size
return -0.5 <= relative.X and relative.X <= 0.5
and -0.5 <= relative.Y and relative.Y <= 0.5
and -0.5 <= relative.Z and relative.Z <= 0.5
end
local nbh = {}
nbh.city=
{
name = "city",
coords = Region3.new(Vector3.new(-821,0,644), Vector3.new(101,1300,1546))
}
local loc = "a"
local temploc = "a"
while true do
wait(3)
for _, v in pairs(nbh) do
if isInRegion3(v.coords, pos) then
loc = v.name
else
loc = "notcity"
end
end
if loc ~= temploc then
~~make popup appear~~
temploc = loc
end
end
Despite the player being in the area of "city", the popup appears as "notcity", so I think the problem is in the part that detects whether or not the player is in the region.
Help?

1 comment
thanks.