I’m making a combat system similar to the one found in New World. In New World, you can press Mouse 1 for a light attack, or hold it for a heavy attack. How would I make this without adding a long delay before attacks are registered?
https://developer.roblox.com/en-us/api-reference/function/UserInputService/IsKeyDown
Use the IsKeyDown function from the UserInputService service to check if a key is being held down.
yes but how would this mix with the normal M1 attacks?
make a iskeyup and use the tick() to create and check if more the > 5 or so
and check if holding for more then 5 seconds ig
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.A then --checks if the "A" key is pressed
local count = 1
while wait() do --every 1/60th of a second
if UIS:IsKeyDown(Enum.KeyCode.A) then
count +=1
else
break --break out of while loop
end
end
if count <= 2 then --key held for 2 or fewer frames
--some action
else --key held for more than 2 frames
--do some other action
end
end
end)
wait() can be replaced by tick or some other timing method as the above post suggests. You’ll need to modify the above slightly to fit your needs.