I am making a system where you can scroll to change the item in your hotbar, however if I scroll too fast it makes multiple labels appear large when only one should. I already use a debounce (that’s what the hdb variable is) but it doesn’t make a difference.
This is what it should look like/ what it looks like if I scroll slowly:
This is what it looks like if I scroll too fast:
Script:
local function highlight()
hdb = false
print(equippedslot)
local ui = radial:FindFirstChild("Slot"..equippedslot)
tweenoverride = tweenservice:Create(ui, radialtweeninfo, {Size = UDim2.new(0, 170, 0, 25)}):Play()
ui.FontFace.Bold = true
for i, v in pairs (radial:GetChildren()) do
if v:IsA("TextLabel") and v.Name ~= ui.Name then
v.Size = UDim2.new(0,165,0,20)
v.FontFace.Bold = false
end
end
hdb = true
end
mouse.WheelForward:Connect(function()
local previous = equippedslot
if equippedslot == 1 then equippedslot = 9
else
equippedslot -= 1
end
if hdb then
highlight()
end
for i, v in pairs (radial:GetChildren()) do
if v:IsA("TextLabel") then
v.Size = UDim2.new(0,165,0,20)
v.FontFace.Bold = false
end
end
--feedbacksound
end)
mouse.WheelBackward:Connect(function()
local previous = equippedslot
if equippedslot == 9 then equippedslot = 1
else
equippedslot += 1
end
if hdb then
highlight()
end
--feedbacksound
end)
I’m not quite sure what the problem might be, but have you tried making a part where you force every other label to get to its normal size when the mouse wheel is used?
That’s what the for loop in the highlight function is for. What I think the issue is is that when you scroll fast the for loop doesn’t have time to make all the elements small by the time the function is called again