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

How can I make Shift + C activate my animation?

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

3 comments

0

So, are you trying to active the if statement when a specific combination of keys are pressed?

0

*activate

0

Yeah

1 answer

✓ Accepted answer

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!

1 comment

0

Yap, it works, Thank you so much

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