Ability cooldown timer

I was trying to make a cooldown for a custom ability, but it wouldn’t work, how do I do it? Thanks for the help! (I’m new to the workshop world).

I made two versions.

This first version is very straightforward. When the player is alive and presses Interact, the player is healed 50 HP. Then, it waits (cooldown) 10 seconds or until the player is dead to be usable again.

rule("Custom Ability Ver.2")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Button(Interact)) == True;
		Is Alive(Event Player) == True;
	}

	actions
	{
		Heal(Event Player, Event Player, 50);
		Wait Until(Is Dead(Event Player), 10);
	}
}

This second version uses a variable to store its cooldown in case you want to create a HUD text with it. When the player is alive, presses Interact, and the variable A is 0, the player is healed 50 HP. Then, The variable is set to 10 and starts going down to 0 by 1 point per second (this is the 10 seconds cooldown).

rule("Custom Ability Ver.1")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Button(Interact)) == True;
		Event Player.A == 0;
		Is Alive(Event Player) == True;
	}

	actions
	{
		Stop Chasing Player Variable(Event Player, A);
		Heal(Event Player, Event Player, 50);
		Event Player.A = 10;
		Chase Player Variable At Rate(Event Player, A, 0, 1, Destination And Rate);
	}
}

I’m willing to help, but there’s also a wiki if you need it: https://workshop.codes/wiki

Thank you so MUCH❤️!

1 Like