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

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

Asked by 5 years ago

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)

0
What is it that dosen't work? casper123123123 357 — 5y
0
gui wont appear DuckMaster11211 13 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)

0
Informed is not a valid member of PlayerGUI. DuckMaster11211 13 — 5y
0
Now try duck I used wait for childs! greatneil80 2647 — 5y
Ad

Answer this question