The script listens for user input from the keyboard and loops through each animation in the animations table. If the key code matches the current animation index i, the script checks if the cooldown time has elapsed since the last time that animation was played. If so, it fires the corresponding server event and updates the last animation time in lastAnimationTimes.

This implementation is more scalable since you can add or remove animations simply by modifying the animations table, without needing to modify the script logic for each animation individually.
This script listens for user input from the keyboard
– and fires server events for different animations
– with specified cooldown times.

– Define the animations and their cooldown times and server events
local animations = {
{cooldown = 25/60, event = AnimationEvent1},
{cooldown = 30/60, event = AnimationEvent2},
{cooldown = 20/60, event = AnimationEvent3},
– add more animations here as needed
}

– Create a table to store the last time each animation was played
local lastAnimationTimes = {}

– Listen for user input and fire the corresponding animation server events
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
– Loop through each animation defined in the animations table
for i, animation in ipairs(animations) do
– Check if the input keycode matches the current animation index i
if input.KeyCode == Enum.KeyCode[i] then
– Get the current time
local currentTime = os.clock()

– Check if the cooldown has elapsed since the last time the animation was played
if not lastAnimationTimes[i] or currentTime - lastAnimationTimes[i] >= animation.cooldown then
– Fire the corresponding server event for the animation
animation.event:FireServer()

– Update the last animation time in the lastAnimationTimes table
lastAnimationTimes[i] = currentTime
end
end
end
end
end)