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

Why doesn't my Animation play when I hit the specific hotkey? (Answered!)

Asked by 5 years ago
Edited 5 years ago

It does not show any output whatsoever

Here's the UPDATED script

local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:wait()

local Key = 'E' --Make sure to capitalize it!

local animation = Instance.new("Animation")
animation.AnimationId = 'rbxassetid://2456539535' --The is the appropriate format

local debounce = true

UIS.InputBegan:Connect(function(Input, IsTyping)
 if IsTyping then return end
 local KeyPressed = Input.KeyCode
 if KeyPressed == Enum.KeyCode[Key]and debounce then
    debounce = false
    local LoadAnimation = Char.Humanoid:LoadAnimation("Animation")
    LoadAnimation:Play()
    wait(2)
    debounce = true
 end
end)
0
Try changing 'e' to a capital User#16405 0 — 5y
0
Line 8, the correct formatting should be something like: “rbxassetid://2456539535". xPolarium 1388 — 5y
0
Sorry to all,my mistake.It says 'AnimationID is not a valid member of animation' rochel89 42 — 5y
0
Forget that,just a little typo.Its supposed to be AnimationId.Anyways they say there's an error on line 17 They don't tell me whats wrong rochel89 42 — 5y
0
Nevermind,I got it all sorted thanks for the help all! rochel89 42 — 5y

2 answers

Log in to vote
0
Answered by
Lugical 425 Moderation Voter
5 years ago
Edited 5 years ago

Alright, so I have spotted two issues with the script.

On line 5, you are calling Key to be equal to 'e'. However, as far as I'm aware, UIS keycodes go by the capital letter, so just make a mental note to be aware of that.

As well as that, on line 8, the formatting for the animation is incorrect. Roblox's format this is rbxassetid://[InsertCodeHere]. So it should be replaced with rbxassetid://2456539535.

local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:wait()

local Key = 'E' --Make sure to capitalize it!

local animation = Instance.new("Animation")
animation.AnimationID = 'rbxassetid://2456539535' --The is the appropriate format

local Debounce = true

UIS.InputBegan:Connect(function(Input, IsTyping)
 if IsTyping then return end
 local KeyPressed = Input.KeyCode
 if KeyPressed == Enum.KeyCode[Key]and debounce then
    Debounce = false
    local LoadAnimation =Char.Humanoid:LoadAnimation(Animation)
    LoadAnimation:Play()
    wait(2)
    Debounce = true
 end
end)

All in all, just make sure you have that E capitalized and have the right format for animations. (That format is the same for decals, images, etc.)

0
You kinda helped me with the coding so here's a reward ^-^ rochel89 42 — 5y
Ad
Log in to vote
0
Answered by
HaveASip 494 Moderation Voter
5 years ago
Edited 5 years ago

Your error on line 15 after "debounce" you missed "true", so type this on that line

if KeyPressed == Enum.KeyCode[Key]and debounce == true then
0
It still doesn't work.Is my link to the animation wrong?? rochel89 42 — 5y
0
idk. Your script is correct, so maybe yes HaveASip 494 — 5y
0
Try to change animationid only numbers HaveASip 494 — 5y
0
Ok rochel89 42 — 5y
View all comments (6 more)
0
sadly it doesn't work rochel89 42 — 5y
0
I have one more idea. On line 8 "Animation.AnimationId" change to "animation.AnimationId" HaveASip 494 — 5y
0
I think that might work but I'll try it tomorrow rochel89 42 — 5y
0
k k HaveASip 494 — 5y
0
Debounce and debounce == true are identical if in an if statement. Lugical 425 — 5y
0
ok rochel89 42 — 5y

Answer this question