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

TextLabel appears but does not disappear? What is wrong with the script?

Asked by 9 years ago

Hello. Here is my script for making a ScreenGui TextLabel visible, then invisible. The script makes the Gui visible but doesn't turn it invisible. What is wrong with the script?

Thanks! EDIT: Here is the entire script, to make sure that I am not doing anything else incorrectly that is messing with the GUI

if game.Players.NumPlayers >= 2 then
    playgame()
else
    moreplayers()
end

function playgame()
    print("playgame")
game.Players.PlayerGui.ScreenGui.moreplayers.Visible=false
local beginning = game.Players.PlayerGui.ScreenGui.beginning
beginning.Visible=true
wait(5)
beginning.Visible=false

local modelOfBricks = game.Workspace.spawnwalls 
local nameOfBricks = "spawnwall"

for i,v in pairs(modelOfBricks:GetChildren()) do
    if v.Name == nameOfBricks then
        v.Transparency = 1 
        v.CanCollide=false
    end
end

local go = game.Players.PlayerGui.ScreenGui.go
go.Visible=true
wait(4)
go.Visible=false

wait(10) --END OF ROUND

local roundend = game.Players.PlayerGui.ScreenGui.roundend
roundend.Visible=true
wait(4)
roundend.Visible=false

for i, player in ipairs(game.Players:GetPlayers()) do
    if player.Character then
        local hum = player.Character:FindFirstChild('Humanoid')
        if hum then
            hum.Health = 0
        end
    end
end


modelOfBricks = game.Workspace.spawnwalls
nameOfBricks = "spawnwall"
for i,v in pairs(modelOfBricks:GetChildren()) do
    if v.Name == nameOfBricks then
        v.Transparency = 0 
        v.CanCollide=true
    end
end



function moreplayers()
    print("moreplayers")
    game.Players.PlayerGui.ScreenGui.moreplayers.Visible=true
end

1 answer

Log in to vote
-2
Answered by 9 years ago

You shouldn't use game.StarterGui when manipulating GUIs, but instead use game.Players.(player name).PlayerGuiinstead, because everything in the StarterGui service is cloned into every player's PlayerGui every time they spawn.

0
I changed it to game.Players.PlayerGui, but nothing happened still. Hold on, that's not the whole script. DrCylonide 158 — 9y
0
Still, you need to use the PlayerGui instead of the StarterGui, because the PlayerGui is actually where the GUIs can change. If you change something in the StarterGui, that change will only be seen after the player spawns again. dknj11902 60 — 9y
0
Yeah, I understand that now. I added the entire script to make sure that nothing was interfering with the GUI DrCylonide 158 — 9y
0
You forgot to put the player name in between "game.Players." and ".PlayerGui" If you mean all the players in the game, then you'll have to use "game.Players:GetPlayers()" and run a generic for loop with that. (For help, look up "GetPlayers" on the Wiki) dknj11902 60 — 9y
View all comments (2 more)
0
The wiki page did not help me.. could you give me an example of using GetPlayers in this code? DrCylonide 158 — 9y
0
Honestly, you should provide code with your answer.. because just explaining it through words obviously confused them. Goulstem 8144 — 9y
Ad

Answer this question