local hitbox = script.Parent.magicForestHitbox
while wait() do
local players = game.Players:GetPlayers()
local region = Region3.new(hitbox.Position - (hitbox.Size/2), hitbox.Position + (hitbox.Size/2))
local parts = game.Workspace:FindPartsInRegion3(region)
for i, v in pairs(parts) do
if v.Name == "Head" then
if v.Parent:FindFirstChild("Human") then
--call remote event with v.parent.name
print("player found")
plr = table.find(players, v.Parent.Name)
table.remove(players, plr)
end
end
end
--loop through players calling remote event to stop music
print("player not in region3")
end
There’s no error it just… doesn’t work. It prints “player in region3” sometimes when I’m in the region, sometimes when I’m not… stuff just prints at the wrong times- it’s weird.
EDIT: I did a test, and the region is the correct size, shape, position, whatever, all of that I’m 99% certain is perfect. So why isn’t this working?
I also used scripts to create a new part with the same size and cframe as the region, and it’s size and cframe was exactly the size and cframe i wanted it to be so
while task.wait() do
local players = game.Players:GetPlayers()
local region = Region3.new(hitbox.Position - (hitbox.Size/2), hitbox.Position + (hitbox.Size/2))
local parts = game.Workspace:FindPartsInRegion3(region)
for i, v in pairs(parts) do
if v.Name == "Head" then
if v.Parent:FindFirstChild("Human") then
--call remote event with v.parent.name
print("player found")
plr = table.find(players, game.Players:GetPlayerFromCharacter(v.Parent))
table.remove(players, plr)
end
end
end
--loop through players calling remote event to stop music
for i, v in pairs(players) do
print(v.Name.." is not in region")
end
end