Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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?

0
NOTHING CAME UP ): CKNTOYYS 0 — 5y
0
Two inputs can't fire one event User#24403 69 — 5y
0
What exactly are you trying to do? Igoralexeymarengobr 365 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
Thanks, you was the only that was able to help me out :D User#27525 1 — 5y
0
I'll acept the answer under five minutes, hold on a bit User#27525 1 — 5y
0
Done. User#27525 1 — 5y
Ad

Answer this question