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

I'm trying to make a GUI visible when I click a button, but it won't work. Help?

code here

function onClicked()
  	game.StarterGui.Informed.Frame.TextLabel.BackgroundTransparency = 0.5
	game.StarterGui.Informed.Frame.TextLabel.Text = "The show is starting! Grab a seat and enjoy the show!"
	wait(5)
	game.StarterGui.Informed.Frame.TextLabel.BackgroundTransparency = 1
	game.StarterGui.Informed.Frame.TextLabel.Text = ""
  end
  script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

What is it that dosen't work?

0

gui wont appear

1 answer

The reason the gui will not appear is because you are saying game.StarterGui.Informed

As you see, the player has their own seperate gui's. It is located in game.Players.LocalPlayer.PlayerGui

Lets just say that the startergui clones into the player and is renamed to PlayerGui

Try this:

game.Players.PlayerAdded:Connect(function(plr)
	p = plr -- making the player variable global, even though this is a bad idea, it will still make the script work.
end)
function onClicked()
    p.PlayerGui:WaitForChild("Informed").Frame.TextLabel.BackgroundTransparency = 0.5
    p.PlayerGui.Informed.Frame.TextLabel.Text = "The show is starting! Grab a seat and enjoy the show!"
    wait(5)
    p.PlayerGui:WaitForChild("Informed").Frame.TextLabel.BackgroundTransparency = 1
    p.PlayerGui:WaitForChild("Informed").Frame.TextLabel.Text = ""
  end
  script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

Informed is not a valid member of PlayerGUI.

0

Now try duck I used wait for childs!

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