Toolbar Swapping Cooldown

In my game right now there is a glitch/bug where if you switch between two guns fast enough they will sort of bug together and make a very overpowered gun.

I wanted to know if it was possible and how I could create sort of a 0.5 cooldown between switching tools so that this isn’t possible.

I’m assuming the way this would work would be to detect tool switching and disable the toolbar then re-enable it.

Thank you.

1 Like

In order to make that you would have to use a remote event to switch weapons, I assume you have already written the script to process client-side interaction. Here are the steps the script would take:

  1. Initiate a blank table to log the last time a player changed weapons, but “hook up” the table to a metatable to return a default value of 0, so you don’t have to create a new index in the table whenever a player joins

  2. When a player equips a new weapon, log it to the table like this log[player.Name] = tick()

  3. Check the last time the player equipped a weapon with an if statement:

if  (tick() - log[player.Name]) => 0.5 then
    --give player weapon

If it’s not, then simply make the script return false.