I am trying to do so you hold down e for 5 seconds and then a part gets removed. The closest i have gotten is so you click e 5 times for it to work. I also want it to reset when you let go of the button. This is my code so far:
local UIS = game:GetService(“UserInputService”)
local Count = 0
UIS.InputBegan:connect(function(input,gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if UIS:GetFocusedTextBox() == nil then
for i,v in pairs(game.Workspace.Scrap:GetChildren()) do
local mag = (v.Position-
game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
if mag <= 10 then
if Count >= 5 then
the scrap breaks.
v:Destroy()
else
Count = Count +1
end
end
end
end
else Count = 0
end
end
end)