Not really sure how cooldowns work so I thought a simple wait would work but it doesn't so any help?
local RP = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local HealthDrainDevent = RP:WaitForChild("HealthDrainEvent")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local draining = false
local cooldown = 1
UIS.InputBegan:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
local target = mouse.Target
if target.Parent.Humanoid or target.Parent.Parent.Humanoid then
local TargetHumanoid = target.Parent.Humanoid or target.Parent.Parent.Humanoid
if TargetHumanoid ~= player.Character.Humanoid then
print("Enemy humanoid detected, initiating doom.")
draining = true
while draining == true do
HealthDrainDevent:FireServer(TargetHumanoid)
wait(cooldown)
end
end
end
end
end
end)
UIS.InputEnded:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
draining = false
end
end
end)

1 comment
There is something on the Output?