Play Animation when a Keyboard Key + mouseButton is pressed

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? 2. What is the issue?
    Got 1 Animation that Plays when just pressing mouseButton and want another animation to be played when you for example press ā€œDā€ to walk right + press Mouse while walking

  2. What solutions have you tried so far?
    Screenshot 2024-04-01 230116

throwAnimationTrack is when left clicking

1 Like

something like this should work.

local goingRight = false

game.UserInputService.InputBegan:Connect(function(input: InputObject, gpe: boolean)
	if gpe then return end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if goingRight then
			print("going right and clicking")
		else
			print("only clicking")
		end
	elseif input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.D then
			goingRight = true
		end
	end
end)

game.UserInputService.InputEnded:Connect(function(input: InputObject, gpe: boolean)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.D then
			goingRight = false
		end
	end
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.