Hello there. I'm trying to make a local script so that whenever a player enters a house, a gui will show whose house it is.
local houseRegions = game.Workspace:WaitForChild("HouseRegions") local found = false while wait(1) do for i, v in pairs(houseRegions:GetChildren()) do found = false local region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2)) local parts = 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 then if script.Parent.HouseRegions[v.Name] then script.Parent.House.TextLabel.Text = script.Parent.HouseRegions[v.Name].Value -- it's a string value stored inside a folder called HouseRegions in the starterGui. script.Parent.House.TextLabel.Visible = true for i = 1, 0, -0.1 do script.Parent.House.TextLabel.TextTransparency = i wait(0.05) end wait(1) for i = 0, 1, 0.1 do script.Parent.House.TextLabel.TextTransparency = i wait(0.05) end script.Parent.House.TextLabel.Visible = false break end else script.Parent.House.TextLabel.Text = script.Parent.Mapleburg.Value -- string value script.Parent.House.TextLabel.Visible = true for i = 1, 0, -0.1 do script.Parent.House.TextLabel.TextTransparency = i wait(0.05) end wait(1) for i = 0, 1, 0.1 do script.Parent.House.TextLabel.TextTransparency = i wait(0.05) end script.Parent.House.TextLabel.Visible = false end end end
Everything seems to be working, but the gui that indicates the stuff keeps appearing. (yes I've tried a replica of alvinblox's region3 tutorial.)
Try making it a while [randomval] == true do and when you want it to stop, make the value to false.
local myval = true local num = 0 while myval == true do num = num + 1 print(num) if num == 10 then myval = false end end
Found a solution, even though I had to rewrite the whole script.