Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

6 comments

0

I changed it to game.Players.PlayerGui, but nothing happened still. Hold on, that's not the whole script.

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.

0

Yeah, I understand that now. I added the entire script to make sure that nothing was interfering with the GUI

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)

0

The wiki page did not help me.. could you give me an example of using GetPlayers in this code?

0

Honestly, you should provide code with your answer.. because just explaining it through words obviously confused them.

This discussion is preserved as it was. New answers, comments, and votes are closed.