UI Related Scripts

Hi - Im new to “scripting” and I want to be able to script my buttons so it changes to a darker color and back after clicking. And I tried to script, but I think I did something wrong since it’s not working.
Screen Shot 2020-04-06 at 7.28.27 PM

You will need to use MouseButton1Click for each of your buttons.

Example:

--Player Clicked.
Button.MouseButton1Click:Connect(function()
--Stuff here
end)

If you want to get a dark color if your hovering the button you will need use this instead:

--Player is hovering.
Button.MouseEnter:Connect(function()
--Stuff Here.
end)

--Player is not hovering anymore.
Button.MouseLeave:Connect(function()
--Stuff Here.
end)
1 Like

All UI is cloned from the StarterGui to the player’s PlayerGui container. The active copy of the UI is hence inside the PlayerGui container. So to fix this problem, you must change members of PlayerGui, substituting StarterGui with PlayerGui in your declarations would fix that (ofcourse, don’t do game.PlayerGui, PlayerGui is a child of the Player object, get it using game.Players.LocalPlayer)

2 Likes