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

How can I make Shift + C activate my animation?

Asked by 4 years ago
Edited 4 years ago
uis.InputBegan:Connect(function(key, gameProcessed)

    if key.KeyCode == **Enum.KeyCode.C** then


        if isCrawling then

            isCrawling = false  

            if loadedCrawlAnim then loadedCrawlAnim:Stop() end  

            loadedIdleAnim:Stop()           

            game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 16, 50)

        elseif not isCrawling then

            isCrawling = true   

            loadedIdleAnim = humanoid:LoadAnimation(crawlIdle)
            loadedIdleAnim:Play()

            game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 0.5, 20)
        end
    end 
end)


I need to make the key combination activate the animation, "the script is already complete and functional", and if it is possible since there is a plane that is saved with Shift + G, can someone help me? thanks

0
So, are you trying to active the if statement when a specific combination of keys are pressed? BestCreativeBoy 1395 — 4y
0
*activate BestCreativeBoy 1395 — 4y
0
Yeah ManuelCortesYT -1 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I assume that you are trying to activate your animation when a specific combination is pressed. Instead of,

if key.KeyCode == **Enum.KeyCode.C** then

You can try using this:

local uis = game:GetService("UserInputService")

if (key.KeyCode == Enum.KeyCode.LeftShift and uis:IsKeyDown(Enum.KeyCode.C)) or (key.KeyCode == Enum.KeyCode.C and uis:IsKeyDown(Enum.KeyCode.LeftShift)) then

-- [[ Just don't use IsKeyDown on both sides as it may trigger even when the user isn't inputing the combination and another InputBegan function fires ]]

Lemme know if it helps!

0
Yap, it works, Thank you so much ManuelCortesYT -1 — 4y
Ad

Answer this question