In the clip whenever I unhover from the buttons some of them will stay in the hovered position and I have no idea how to fix this. I have literally tried everything I could, I tried running a while true do to check if the player is not hovering over them then to set Scale to 1 but that didn’t work, I tried to make a table of when they hover it will save that button and then if they try to hover while in progress it won’t let them, but somehow it bypasses my code and I am hardstuck on what to do. Here is the code I tried:
function TWEEN.mouseHover(obj)
if not obj or tweensInProgress[obj] == true then return end
local UiScale = obj.UIScale
tweensInProgress[obj] = true
local t = TS:Create(UiScale, TWEEN.infoForTween, {Scale = 1.1})
t:Play()
t.Completed:Wait()
tweensInProgress[obj] = false
end
function TWEEN.mouseLeave(obj)
if not obj or tweensInProgress[obj] == true then return end
local UiScale = obj.UIScale
tweensInProgress[obj] = true
local t = TS:Create(UiScale, TWEEN.infoForTween, {Scale = 1})
t:Play()
t.Completed:Wait()
tweensInProgress[obj] = false
end
If anyone has an idea on how to make this work when the player hovers over a bunch at a time it would be appreciated.
You’re overlapping tweens and because tweens can’t be changed once played, the size isn’t set to the one you want. Seeing you have a tweensInProgress table, if a tween on the object is playing, cancel it and then play the new tween
function IconUX.ShrinkOnGuiStateChange(providedFrames : typeof({}))
for i, frame in providedFrames do
frame:GetPropertyChangedSignal("GuiState"):Connect(function()
local currentMousePosition = UIS:GetMouseLocation()
local hoveredObjects = PlayerGui:GetGuiObjectsAtPosition(currentMousePosition.X, currentMousePosition.Y)
if table.find(hoveredObjects, frame) then
return
end
task.wait(0.08)
if frame.GuiState == Enum.GuiState.Idle then
IconUX.Shrink(frame) -- Replace this whatever function you need
end
end)
end
end
My module already checks for that, just add any frames you want and replace the shrink.
If you don’t plan on using this, then my only recommendation is not using an infinite loop, b/c that slightly loses performances while not necessary.
function TWEEN.mouseHover(obj)
local UiScale = obj.UIScale
if tweensInProgress[obj] and tweensInProgress[obj].PlaybackState == Enum.PlaybackState.Playing then
tweensInProgress[obj]:Cancel()
end
local tween = TS:Create(UiScale, TWEEN.infoForTween, {Scale = 1.1})
tweensInProgress[obj] = tween
tweensInProgress[obj]:Play()
end
function TWEEN.mouseLeave(obj)
local UiScale = obj.UIScale
if tweensInProgress[obj] and tweensInProgress[obj].PlaybackState == Enum.PlaybackState.Playing then
tweensInProgress[obj]:Cancel()
end
local tween = TS:Create(UiScale, TWEEN.infoForTween, {Scale = 1})
tweensInProgress[obj] = tween
tweensInProgress[obj]:Play()
end
wait i found the issue i just had to write 4 lines of codes OMG
function TWEEN.mouseHover(obj)
local t = TS:Create(obj.UIScale, TWEEN.infoForTween, {Scale = 1.1})
t:Play()
end
function TWEEN.mouseLeave(obj)
local t = TS:Create(obj.UIScale, TWEEN.infoForTween, {Scale = 1})
t:Play()
end
IDK how this works but im not touching it so it works