Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

UserInputServer Not working correctly?

Asked by 5 years ago
Edited 5 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

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)`

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. User#20279 0 — 5y
0
Local scripts can only run under the player so try puting the script in startpack Vain_p 78 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question