Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Cooldown with debounce making the attack on infinte cooldown how do i make it doing normal cooldown?

I tried making a cooldown with debounce but when i use the move i cant use it again after the cooldown time passed

local player = game.Players.LocalPlayer local service = game:GetService("UserInputService") local sound = Instance.new("Sound") local rp = game:GetService("ReplicatedStorage") local Texas = rp:WaitForChild("Texas") local debounce = false local cooldown = 10

sound.SoundId = "rbxassetid://3545356912" sound.Parent = script.Parent sound.Volume = 0.3

service.InputBegan:Connect(function(input, isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.E then if debounce == false then debounce = true

		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://7491517614"
		sound:Play()
		
		player.Character.Humanoid:LoadAnimation(anim) :Play()

		wait(0.2)

		local HumanRoot = player.Character.HumanoidRootPart
		script.SmashEvent:FireServer(HumanRoot)
		Texas:FireServer()
	end
end

end)

Texas.OnClientEvent:Connect(function() wait(cooldown) debounce = false end)`

1 answer

✓ Accepted answer

debounce on different scripts are different, because no script share the same variable, you should disable debounce on the server script (after Texas:FireServer())

Below the Texas:FireServer() code, put wait(cooldown) debounce = false, and delete the code Texas.OnClientEvent:Connect(function() wait(cooldown) debounce = false end) because it's wrong

1 comment

0

the brackets after connect are just information that is passed into the other script - it doesnt run the code in the brackets * just a thing to add!

This discussion is preserved as it was. New answers, comments, and votes are closed.