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

how do i make my TextButton’s properties change whenever a player’s mouse is hovering over it?

Asked by
Grazer022 128
3 years ago
Edited 3 years ago
local mainGui = game.StarterGui.MainGui
local shopButton = mainGui.ShopButton
local shopHoverC = 10,20,10
local shopHoverS = 15,5,10,0

function shopButtonHovering()
   shopButton.Size = Udim2.new(shopHoverS)
   shopButton.BackgroundColor3 = Color3.new(shopHoverC)
end

I want it that when a player’s mouse hovers on shopButton it will run the function. Is there some event that makes it work? Also should it be in a LocalScript? Thanks!

2 answers

Log in to vote
0
Answered by
Subsz 366 Moderation Voter
3 years ago

You can simply use the MouseEnter function

local mainGui = game.StarterGui.MainGui
local shopButton = mainGui.ShopButton
local shopHoverC = 10,20,10
local shopHoverS = 15,5,10,0

function shopButtonHovering()
   shopButton.Size = Udim2.new(shopHoverS)
   shopButton.BackgroundColor3 = Color3.new(shopHoverC)
end

shopButton.MouseEnter:Connect(shopButtonHovering)
0
I didn't saw someone already answered it XD DavidMind67 -8 — 3y
0
cant you use local functions instead of global? SilentsReplacement 468 — 3y
0
thanks for the help! Also using global functions still works :V Grazer022 128 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

There is an event called "MouseEnter" in TextButton

script.Parent.MouseEnter:Connect(function() script.Parent.TextColor3 = Color3.fromRGB(255, 255, 255) end)

script.Parent.MouseLeave:Connect(function() script.Parent.TextColor3 = Color3.fromRGB(0, 0, 0) end)

Answer this question