Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gui keeps appearing even though I break the loop?

Asked by
bluzorro 417 Moderation Voter
4 years ago

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.)

0
Your only breaking the for loop, not the while wait loop SmartNode 383 — 4y
0
Which line is it? marioman1932 48 — 4y
0
it's not an error. the script works fine but the screengui keeps appearing even though i break the for loop. bluzorro 417 — 4y

2 answers

Log in to vote
0
Answered by
1lO_Ql1 -1
4 years ago
Edited 4 years ago

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
0
it wouldn't work if i do that either. bluzorro 417 — 4y
Ad
Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
4 years ago

Found a solution, even though I had to rewrite the whole script.

Answer this question