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

How to require multiple user inputs to run a certain function? (Custom Movements)

Asked by 4 years ago

I'm currently in the conceptual stages of an extreme sports type game, much like the game SHRED. In that game, different motions, such as grabs, tweaks, or body varials, are binded to different keys along with a direction.

(EX: Shift + Right = Melon Grab)

I want to be able to detect if the player were pressing a certain button and a direction to create specific combinations.

Additionally

How can I make it to where a player is in a "custom state", like I can set a variable in the player that isn't given from the roblox engine, I want to be able to set the player to be hypothetically "inTrick" state to detect whether a trick was landed or not.

Thank you for reading my question, I'm really excited to learn and go through the process of game development.

0
aw heeel yeah SHRED is an awesome game but very glitchy, i'll write an answer but i cannot wait to see what you make User#25069 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Probably not the most in-depth explanation, but whatever.

For this, I'd suggest UserInputService which can access what buttons the player is pressing.

You'd first want to import it.

local UIS = game:GetService("UserInputService")

Then when you detect a new input, you want to check for combinations of keys pressed (for this I'll be using the one you mentioned but you can replace the Enum.KeyCode. with whatever keys you like.

UIS.InputBegan:Connect(function()
    if UIS:IsKeyDown(Enum.KeyCode.LeftShift) and UIS:IsKeyDown(Enum.KeyCode.Right) then
        doMove() --replace this with the function which performs the move (eg. melon grab)
    end
end

Hope I covered everything, feel free to ask any questions. I haven't tested this and I can notice some possible problems that may arise but I'll leave that to you. Good luck. :)

0
Ahhh yes thank you, I haven't thought of using and if and statement. Also, I've been using Context Action Service instad of UserInputService. I don't know how to post my code into a comment, but I used this video to help me https://www.youtube.com/watch?v=lrb80TgoW0M. Thank you again. XxD3m0nSn1p3rXx 7 — 4y
Ad

Answer this question