local background = game.Players.PlayerGui.ScreenGui.BackGround local Creditsbutton = game.Players.PlayerGui.ScreenGui.BackGround.CreditsButton local TextLabel =game.Players.PlayerGui.ScreenGui.BackGround.TextLabel function OnClicked() background.BackgroundTransparency = 1 Creditsbutton.Visible = false TextLabel.Visible = false end
Obviously, I want the background to become transparent when the player clicks play. Why is it not working?
There's two issues with the script you've provided us with.
To fix these two issues and to get the result you want, you need to connect the 'OnClicked' function to the MouseButton1Click event of the 'Play' button. You also need to get the LocalPlayer. An example fix is below.
local Player = game.Players.LocalPlayer local Gui = Player.PlayerGui.ScreenGui local Background = Gui.BackGround local CreditsButton = BackGround.CreditsButton local TextLabel = Background.TextLabel local PlayButton = --// You need to fill this out. function Clicky() Background.BackgroundTransparency = 1 CreditsButton.Visible = false TextLabel.Visible = false end PlayButton.MouseButton1Click:connect(Clicky)
Do remember that the PlayButton variable needs to be filled out and that the PlayButton should be an ImageButton or a TextButton. It should also be noted that you don't necessarily have to get the LocalPlayer - If the script is in the GUI, or is in the PlayButton, you can quite easily just parent up. However, seeing as you didn't say where it's located, I operated under the assumption that the script is outside of the GUI.
It is also worth noting that a function can be named anything you like and doesn't need to resemble the name of the event you're planning to use.
If this doesn't work, please provide what the output spits out.