Scroll Item Browsing isn't working

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:
image

This is what it looks like if I scroll too fast:
image

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)

Thanks for helping me out!

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

Okay sorry, I’m not an expert, the only thing I can think of would be to either make another function or wrap it in a coroutine

Ur good. I’ll try wrapping it in a coroutine. Wdym by making another function?

You make another Function by doing local function

I see what you were thinking, unfortunately wrapping it in a coroutine did not work :frowning:

Sorry for the confusing question, I meant what would the new function be for?

Run the for loop, other thing I can think of is either use task.spawn or using a completely different script

I tried that but it still isn’t working

I don’t know how to help then, maybe add a wait statement towards the end? Or maybe make a fe ounce and disable it once the for loop is finished

Or (not the best) make a script to handle each one singulraly

1 Like

I figured out the issue, I put the for loop in a runservice loop that constantly made every element small excepting the selected item slot

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.