Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a script where it starts and finishes with 2 inputs at the same time?

Tittle says it all. Here's the script i'm have trouble with:

game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.R and input.KeyCode == Enum.KeyCode.F then
print("Started")
end
end)
game:GetService("UserInputService").InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.R and input.KeyCode == Enum.KeyCode.F then
print("Ended")
end
end)

Can someone explain why don't it work with 2 keycodes, but only with one?

3 comments

0

NOTHING CAME UP ):

0

Two inputs can't fire one event

0

What exactly are you trying to do?

1 answer

✓ Accepted answer

This is the best way i can think of to do what your trying to achieve

I used a Debounce to see if Ready was true in order for the F key to work

local Ready = false

game:GetService("UserInputService").InputBegan:Connect(function(Key, Chat)

    if Key.KeyCode == Enum.KeyCode.R and not Chat and not Ready then

	    Ready = true

	    print("R Began Ready = true")

    end

end)

  

game:GetService("UserInputService").InputBegan:Connect(function(Key, Chat)

    if Key.KeyCode == Enum.KeyCode.F and not Chat and Ready then

	    print("Read is already True, F")

    end

end)

game:GetService("UserInputService").InputEnded:Connect(function(Key, Chat)

    if Key.KeyCode == Enum.KeyCode.R and not Chat and Ready then

	    Ready = false

	    print("R Ended, Ready = false")

    end

end)

3 comments

0

Thanks, you was the only that was able to help me out :D

0

I'll acept the answer under five minutes, hold on a bit

0

Done.

This discussion is preserved as it was. New answers, comments, and votes are closed.