Sorry if this is the wrong category. This is my first post…
Hello! I’m trying to create a magic move where if you hold a key, then you’ll be able to charge up a magic attack. It’s similar to Kamehameha. I want it so you have to hold the R key for 4 seconds for the magic attack to render. I tried using if statements, but that didn’t work…
If you could give me some things I should do, that would be great! Also sorry if the question sounds basic, i’m a basic scripter.
Also, I didn’t include the full script because i’m just planning it out right now.
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode.R then
if input.KeyCode == Enum.KeyCode.R then
if input.KeyCode == Enum.KeyCode.R then
if input.KeyCode == Enum.KeyCode.R then
So what you do is check if the person hit the R key four times but it resets each time because a new UIS is fired. Instead, you’d want to get the time the person hit R, and check if not released in a while loop.
Hello, I know of two ways to do this, the first is using iskeydown and the second is doing a while loop inside the input conditional. I don’t recommend using iskeydown because I used it and it gave my systems some problems…