Answered by
4 years ago Edited 4 years ago
For the slot system you can make value that will increase every time you press the Q button, and if the slot is higher than your max then reset it back to default.
01 | local UserInputService = game:GetService( 'UserInputService' ) |
07 | UserInputService.InputBegan:Connect( function (input,gameProccesedEvent) |
08 | if input.KeyCode = = Enum.KeyCode.Q and debounce = = false then |
10 | slot = (slot % maxSlots) + 1 |
Basically the line with adding slot what it does:
It adds +1 to the slot, and it uses the modulus operator on the number, the modulus returns how much is left when divided by the number so: 10 % 2
= 0 left but 10 % 4
= 2, because 4 can fit 2 times into 10 but 4*2 = 8 so 10 - 8 is 2 which is the number it returns.
about %
EDIT:
Here is how to split it into 2 lines
1 | UserInputService.InputBegan:Connect( function (input,gameProccesedEvent) |
2 | if input.KeyCode = = Enum.KeyCode.Q and debounce = = false then |