How can i make an animation play when the player presses Q

pretty simple how can i make the player do an animation when they press Q
i just need the script not the animation

3 Likes
local UserInputService = game:GetService("UserInputService")
local Animation = YourAnimationHere
local Key = Enum.KeyCode.Q

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Key then
		print("Q was pressed!")
		Animation:Play()
	end
end)

tbh you could’ve searched it up and get the answer you want

5 Likes

That only plays it locally though right?

2 Likes

yeah it needs to be a local script
So the solution to that would be to send a remote event and play the animation from there

1 Like

lemme try this
i posted on devforum since its more specific and easier to communicate

where do i put the script?

In a local script, StarterPlayerScripts for example.

1 Like

im kinda confused i have a local script in StarterPlayerScripts and i put my animation id but it doesnt work i didnt expect it to work but im not rly sure why it doesnt

Could you send the code you are using?

ive got the code working thank you to everyone that helped

2 Likes

No, animations played through client-controlled characters will replicate to the server.
https://developer.roblox.com/en-us/api-reference/class/Animator

3 Likes