Most Efficient way to make a charging attack

I want to make a magic attack where depending on the amount of time you charge the bigger the attack is but I have no idea where to start.

To achieve this, you would find the time that has passed.

local Clock = os.clock()
local UIS = game:GetService("UserInputService")
local StartTime = os.clock() - Clock

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		StartTime = os.clock() - Clock
	end
end)

UIS.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
		local EndTime = os.clock() - Clock
		local Damage = EndTime - StartTime
		print(Damage)
	end
end)


9 Likes