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

Yet Another MouseEnter/MouseLeave Function Problems?

I've been doing MouseEnter and MouseLeave functions for Guis on Roblox for years now, and it hasn't failed me one time (except spelling errors, but that's not the point), however, the code I have for the menu I am creating for fun (which, by the way, is not fun now) isn't working properly, well, the Mouse functions aren't. I checked back multiple times to see if I had any errors in my spelling, locals, etc. and found no error whatsoever, and this is getting me on my nerves now. In StarterGui, I have a ScreenGui called 'MainMenu', and inside the ScreenGui, I have a Frame named 'Background', and in the Frame, I have four objects: two TextButtons I have is named 'StartButton' and 'AboutButton', a TextLabel named 'Title', and a LocalScript called 'MenuCode'. Here's my code in the LocalScript

--\\ Services


local Players = game:GetService('Players').LocalPlayer
local StarterGui = game.StarterGui
local Menu = StarterGui.MainMenu
local Background = Menu.Background
local Start = StarterGui.MainMenu.Background.StartButton
local About = StarterGui.MainMenu.Background.AboutButton
local Title = StarterGui.MainMenu.Background.Title


--\\ Mouse enter/leave (Start/About buttons)


function MouseEnterStartButton()
	Start.FontSize = Enum.FontSize.Size32
end


function MouseLeaveStartButton()
	Start.FontSize = Enum.FontSize.Size28
end


function MouseEnterAboutButton()
	About.FontSize = Enum.FontSize.Size32
end


function MouseLeaveAboutButton()
	About.FontSize = Enum.FontSize.Size28
end


--\\ Recalling functions


Start.MouseEnter:connect(MouseEnterStartButton)
Start.MouseLeave:connect(MouseLeaveStartButton)


About.MouseEnter:connect(MouseEnterAboutButton)
About.MouseLeave:connect(MouseLeaveAboutButton)

This issue is getting on my nerves since I am always able to do this, and now Roblox is acting on me now. Can you help me fix this issue?

2 comments

0

Can you check if the script is running at all? Because other than than everything looks fine.

0

I looked at the script and disabled and reenabled it, still doesn't work.

1 answer

✓ Accepted answer

You are connecting your events to the gui elements in StarterGui rather than the gui elements that are local to the player. To fix this you should change

local StarterGui = game.StarterGui

to

local StarterGui = Players.PlayerGui

1 comment

0

Well that was stupid, I always made it to PlayerGuI, guess it slipped by me, thanks!

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