To clarify, I have this single script control all of the MouseEnter code for my menu system’s buttons. These also play a sound everytime the mouse hovers over the button. However, if the player moves their mouse rapidly over the buttons before the sound is able to finish, it suddenly cuts off the previous instance and begins anew. The only solution I could think of was having this script split up into many ones for everyone of the buttons, but that would cause unnecessary clutter. Anyway I can do this or make it more efficient?
Code:
local GUI = script.Parent.Parent
local CommunicationsRing = script.Parent.Communications
local FriendsRing = script.Parent.FriendsGuild
local InventoryRing = script.Parent.InventoryPlayerStatus
local MapsQuestRing = script.Parent.MapsQuest
local SettingsOptionsRing = script.Parent.SettingsOptions
local HoverSound = GUI.Sounds.HoverSound
---------------------------- Menu Buttons
CommunicationsRing.MouseEnter:Connect(function()
HoverSound:Play()
CommunicationsRing.Image = "rbxassetid://13188408348"
end)
CommunicationsRing.MouseLeave:Connect(function()
CommunicationsRing.Image = "rbxassetid://13132124790"
end)
FriendsRing.MouseEnter:Connect(function()
HoverSound:Play()
FriendsRing.Image = "rbxassetid://13188450519"
end)
FriendsRing.MouseLeave:Connect(function()
FriendsRing.Image = "rbxassetid://13132084486"
end)
InventoryRing.MouseEnter:Connect(function()
HoverSound:Play()
InventoryRing.Image = "rbxassetid://13188466368"
end)
InventoryRing.MouseLeave:Connect(function()
InventoryRing.Image = "rbxassetid://13131144116"
end)
MapsQuestRing.MouseEnter:Connect(function()
HoverSound:Play()
MapsQuestRing.Image = "rbxassetid://13188471390"
end)
MapsQuestRing.MouseLeave:Connect(function()
MapsQuestRing.Image = "rbxassetid://13132196399"
end)
SettingsOptionsRing.MouseEnter:Connect(function()
HoverSound:Play()
SettingsOptionsRing.Image = "rbxassetid://13188476877"
end)
SettingsOptionsRing.MouseLeave:Connect(function()
SettingsOptionsRing.Image = "rbxassetid://13132200939"
end)