I need help with my custom hotbar script

Ok, so I started designing my own custom hotbar script a few days ago. I wrote a module to handle the highlighting of the buttons on the hotbar. Whenever the player presses a number key, it selects that box in their hotbar. I scripted almost all of the aesthetic handling code, but I got stuck. I’m trying to make it where if you press a number that’s from 1-6, it’ll highlight that number’s box in the hotbar.
I can’t figure out how to make it where if one button is highlighted and the player selects another, the other one is deselected. Can I get some help?

Thanks,

Hulk

when you press any number:

have a variable called previousBox
when you press a button (select a box) do something along the lines of this:

if previousBox ~= nil then
	--TODO: make previous box unselected here
end

--TODO: select the box that corresponds to the number you just pressed
previousBox = the box we just selected

let me know if you need help coding that.

2 Likes

Thanks, I’ll try that. Be back in a few with the results!