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

Yet Another MouseEnter/MouseLeave Function Problems?

Asked by 7 years ago

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?

0
Can you check if the script is running at all? Because other than than everything looks fine. Link150 1355 — 7y
0
I looked at the script and disabled and reenabled it, still doesn't work. GreekGodOfMLG 244 — 7y

1 answer

Log in to vote
3
Answered by
magnalite 198
7 years ago

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

0
Well that was stupid, I always made it to PlayerGuI, guess it slipped by me, thanks! GreekGodOfMLG 244 — 7y
Ad

Answer this question