its a localScript i put it in starterCharacterScripts because if i put it in StarterPlayerScripts when i die it wont work
local UserInputService = game:GetService('UserInputService') local debounce = false UserInputService.InputBegan:Connect(function(input,gameProccesedEvent) if input.KeyCode == Enum.KeyCode.Q and debounce == false then print("Q") end end)
i made some modifications to the Local Script and it broke so i had to make a new one
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.
local UserInputService = game:GetService('UserInputService') local debounce = false local slot = 1 local maxSlots = 10 UserInputService.InputBegan:Connect(function(input,gameProccesedEvent) if input.KeyCode == Enum.KeyCode.Q and debounce == false then print(slot) slot = (slot % maxSlots) + 1 end end)
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.
EDIT: Here is how to split it into 2 lines
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent) if input.KeyCode == Enum.KeyCode.Q and debounce == false then print(slot) slot = (slot + 1) ... slot = slot%maxSlots end end)