Hey I am making a game and wrote a script to play a emote when you press a key and it does work in studio but in the the game (not in studio test) it dosent work this is my script
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() local character = player.Character or player.CharacterAdded:Wait() local Humanoid = character:WaitForChild("Humanoid") local uis = game:GetService('UserInputService') local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://6712486204" -- bla bla bla bla function onKeyPressed(inputObject,gameProcessEvent) if inputObject.KeyCode == Enum.KeyCode.R then Humanoid:LoadAnimation(anim):Play() print("Animation is playing") end end uis.InputBegan:Connect(onKeyPressed)
Unless there is something wrong with your script, it could be that the animation doesn't belong to your account. If that is the case it is unplayable using your key bind.
You COULD make your own animations using the ROBLOX Animator, or find free ones from the Toolbox and upload those if you find that too difficult. It's a learning process to make super detailed animations and can be a pain sometimes. There's even ways to take other people's animations, like the one seen in your script assuming it doesn't belong to you. It's stealing, I know, but in the end I don't think anyone cares. For more info on this DM me at noboundaries1#6198 on Discord for a full walkthrough.
This can be because the animation you want to play is not made by the creator of the game. You cannot play animations made by users who are not the developers of the game.
What you should do instead is recreate the animation on your own. Here is an useful guide on how to animate using the Roblox animation editor. You can also search up for youtube tutorials on how to animate.