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

UserInputServer Not working correctly?

For some reason my UserInputService is working. I have it set up to where if a certain key was pressed, E, an animation would be loaded into the character and the animation would play. After a few failed attempts, I tried a print function, but turns out that doesn't work either. The entire thing doesn't even run when the button is pressed.

The code is simple, just a few lines, which is in a LocalScript which is in the StarterPlayerScript. I have also tested it in StarterGui but that didn't work either.

`local uis = game:GetService("UserInputService")

local player = game.Players.LocalPlayer

local char = player.Character

uis.InputBegan:Connect(function(input)

if input == Enum.KeyCode.E then

local smash = Instance.new("Animation")

smash.AnimationId = 'rbxassetid://2941877623'

local usos = char.Humanoid:LoadAnimation(smash)

usos:Play()

end

end)`

2 comments

1

Put "input.KeyCode" instead of just "input". Also I'm not sure if this is required but also parent the animation somewhere, preferably the character.

0

Local scripts can only run under the player so try puting the script in startpack

1 answer

Your script is correct, just make sure that it is a LocalScript and put it in the StarterGUI. Do try and tell me if it works or not.

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