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

How do I fix a GUI problem?..

So Im making a mini game and when I tell the GUI to change it wont.. every time you die it dose but I want the gui to change smoothly.. help please.

minigames = game.Lighting.Minigames:GetChildren()
h = game.StarterGui.Ament.TextLabel

while true do
	
	if game.Players.NumPlayers > 1 then
		h.Text = "Choosing Game..."
		wait(3)
		ranGame = math.random(1, #minigames)
		gameChosen = minigames[ranGame]
		h.Text = "Minigame Chosen: " .. gameChosen.Name
		wait(3)

1 comment

0

Use while wait() do instead of while true do

1 answer

You're changing the StarterGui object. StarterGui basically clones and resets Guis in a Player's PlayerGui on reset. Which means, anything you add or change in StarterGui will not appear after you respawn. A way you can avoid this is using a for loop to go through all players of the game, and change that label.

minigames = game.Lighting.Minigames:GetChildren()

while true do

    if game.Players.NumPlayers > 1 then
        for _,v in pairs(game.Players:GetChildren()) do --:GetChildren sets up a table of objects (or the players), the for loop will go through all players until it is done.
			v.PlayerGui.Ament.TextLabel.Text = "Choosing Game..." --PlayerGui is what is displayed to the user in real time, changes here are seen.
		end
        wait(3)
        ranGame = math.random(1, #minigames)
        gameChosen = minigames[ranGame]
		for _,v in pairs(game.Players:GetChildren()) do --Same thing here.
			v.PlayerGui.Ament.TextLabel.Text = "Minigame Chosen: " .. gameChosen.Name
		end
        wait(3)

Warning; will not work if filtering enabled is enabled.

1 comment

0

So I tried that and it isn't working... But I did add some stuff for other announcements so that might be the problem? Would you like to see the full script?

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