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

I need help with UIS, my animation is not playing. What is wrong?

Asked by
valchip 789 Moderation Voter
5 years ago
local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:FindFirstChild("Humanoid")

game:GetService('UserInputService').InputBegan:Connect(function(input)
    print("test")
    if input.KeyCode == Enum.KeyCode.E and plr and chr then
        local emote = script.Animation
        emote.AnimationId = "rbxassetid://1977787384"
        local animloader = hum:LoadAnimation(emote)
        animloader:Play()
    end
end)

That is the script. What is wrong?

0
Is it the animation not playing or the whole function? SulaymanArafat 230 — 5y
0
Animation not playing only. valchip 789 — 5y
0
Check output, are you sure you own the animation? SulaymanArafat 230 — 5y
0
In output it may also say if the asset couldn't load because it's not yours or something SulaymanArafat 230 — 5y
View all comments (2 more)
0
It is mine and also I own it. valchip 789 — 5y
0
This will not load after the first time you die, mind User#6546 35 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

When it comes to animation, there are a few things you must know.

  1. You must OWN the animation. This means you have exported it.

  2. Make sure the animation's PRIORITY is set to ACTION this will guarantee it to overlap Roblox's Default animations with some exceptions.

  3. Make sure you actually have the animation as an object.

  4. Make sure when you do :LoadAnimation() it's being done on a Humanoid

Alright now that you know this and confirmed it here is your fixed script:

local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:FindFirstChild("Humanoid")
local UIS = game:GetService('UserInputService')

UIS.InputBegan:Connect(function(input, IsTyping)
    if IsTyping then return end
    print("test")
    if input.KeyCode == Enum.KeyCode.E and chr then
        local emote = Instance.new('Animation')
        emote.AnimationId = "rbxassetid://1977787384"
        local LoadAnimation= hum:LoadAnimation(emote)
        LoadAnimation:Play()
    wait(3)
    emote:Destroy()
    end
end)

This should work if you happen to find a bug or error comment below. Anyway, I hope I helped.

Here is some information on Animations: http://wiki.roblox.com/index.php?title=Animations

Best of luck to you and hope it's fixed!

0
thanks valchip 789 — 5y
0
np BlackOrange3343 2676 — 5y
Ad

Answer this question