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

Fix this gui script about gui staying on all the time plz ?

Asked by
Glvt102 11
3 years ago
Edited 3 years ago

Well, basically what happens, BOTH sounds play at the same time and "Kill all enemies" gui stays on screen all the time and it doesn't even reach "all enemies dead". halp

local s = Instance.new("Sound")
s.Name = ("Bellsounde")
s.Parent = game.Workspace
s.SoundId = "rbxassetid://138258242"
s.Volume = 4
local e = Instance.new("Sound")
e.Name = ("Bellsound")
e.Parent = game.Workspace
e.SoundId = "rbxassetid://6891548543"
e.Volume = 4

game.Workspace.trap.Touched:Connect(function()
    for _,player in pairs(game.Players:GetPlayers()) do
        for _,player in pairs(game.Players:GetPlayers()) do
            player.PlayerGui.KILLALLENEMIES2.Enabled = true
            e:Play()
            wait(2)
            player.PlayerGui.KILLALLENEMIES2.Frame.Visible = 0
    end
    wait(5)
    for _,player in pairs(game.Players:GetPlayers()) do
        player.PlayerGui.ALLENEMIESDEAD2.Enabled = true
        s:Play()
        wait(2)
            player.PlayerGui.ALLENEMIESDEAD2.Frame.Visible = 0
            end
        end
        end)

2 answers

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

It seems to me that you put an 'end' keyword in the wrong place. You should also use true or false when setting the visibility of a Frame (or any element for that matter).

game.Workspace.trap.Touched:Connect(function()
    for _,player in pairs(game.Players:GetPlayers()) do
        for _,player in pairs(game.Players:GetPlayers()) do
            player.PlayerGui.KILLALLENEMIES2.Enabled = true
            e:Play()
            wait(2)
            player.PlayerGui.KILLALLENEMIES2.Frame.Visible = false -- true/false required
        end -- 'end' added here
    end
    wait(5)
    for _,player in pairs(game.Players:GetPlayers()) do
        player.PlayerGui.ALLENEMIESDEAD2.Enabled = true
        s:Play()
        wait(2)
        player.PlayerGui.ALLENEMIESDEAD2.Frame.Visible = false -- true/false required
        -- you had an 'end' here (removed)
    end
end)

If this worked, I would appreciate the answer being accepted. If it did not help you, please give a more detailed explanation of what should or should not be happening and I will try to assist you.

EDIT I noticed that you had 2 'for' loops (1 nested) that do the exact same things. You only needed one.

game.Workspace.trap.Touched:Connect(function()
    for _,player in pairs(game.Players:GetPlayers()) do
        -- 'for' loop removed
            player.PlayerGui.KILLALLENEMIES2.Enabled = true
            e:Play()
            wait(2)
            player.PlayerGui.KILLALLENEMIES2.Frame.Visible = false -- true/false required
    end
    wait(5)
    for _,player in pairs(game.Players:GetPlayers()) do
        player.PlayerGui.ALLENEMIESDEAD2.Enabled = true
        s:Play()
        wait(2)
        player.PlayerGui.ALLENEMIESDEAD2.Frame.Visible = false -- true/false required
        -- you had an 'end' here (removed)
    end
end)
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hey there!

Instead of "0" beside "Frame.Visible" you need to put a true or false statement.

True meaning yes. False meaning no.

-- So if you want the frame to not be visible do:

Frame.Visible = false

-- If you want it to be visible do:

Frame.Visible = true.

If I helped, please accept this answer as solved! Not only will I get a reward, but you will too!

Edit: If it didn't work, try setting it to false.

0
Uh uh, doenst work Glvt102 11 — 3y
0
So you want the GUI to go? SonGohan6 85 — 3y

Answer this question