Hi, I'm trying to make a script that detects which "box" you're in and then create/edit one attribute depending on which you're in. For instance, if you're not in any box the default is "none." But if you walk into the red box then it'd become "redBox." When you leave the box it's defaulted back to "none." The issue here is that it's completely ignoring the "redBox" instance's name. My script is below.
local testingRegionsBoxes = game.Workspace:WaitForChild("regionTestingBoxes")
local redBox = game.Workspace.regionTestingBoxes.redBox
local greenBox = game.Workspace.regionTestingBoxes.greenBox
local found = false
local player = script.Parent.Parent
while wait(1) do
for i, v in pairs(testingRegionsBoxes:GetChildren()) do
found = false
player:SetAttribute("Zone", "none")
local region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
found = true
break
else
found = false
end
end
if found == true then
print(v)
player:SetAttribute("Zone", v.Name) --here is the issue, instead of making it "redbox" it will make it "none" and will only work if the box is "greenBox"
end
end
end
I also have screenshots of the instance as well as proof that it can actually read the object, but it refuses to set it as the value of an attribute. I'll post the output below. Thanks for reading

2 comments
https://cdn.discordapp.com/attachments/723045193292447768/841890571316363294/unknown.png working screenshot, zone attribute is how I want it
https://cdn.discordapp.com/attachments/723045193292447768/841890678912843776/unknown.png not working screenshot, zone attribute is "none" instead of "redBox"