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

My animation is not working when I test it in game?

Asked by
ExcelUp 24
6 years ago

I have a keybind animation script that plays an animation keybinded to the keyboard character 'E'. This animation is a custom animation, made by myself, and it works completely fine when I test it in Studio. Despite this, when I have my friends try it in test mode, it does not show or activate, and it doesn't show or activate for both myself and my friends when I try it in the actual game. Can someone help me please?

local animations = {
                --Add your animations here like this format
                [Enum.KeyCode.E] = 1248423203,--Plays when "K" is pressed wolfie animation
                --You can add a whole bunch more, just be careful not to overwrite one key with two animations :D

    }



repeat wait() until game.Players.LocalPlayer; local player = game.Players.LocalPlayer
repeat wait() until player.Character; local character = player.Character
local currentAnimId,currentPlaying = '',nil
local humanoid = character:FindFirstChild('Humanoid')
local uis = game:GetService('UserInputService')

uis.InputBegan:connect(function(input,gpe)
    if not gpe then
        if animations[input.KeyCode] ~= nil then
            local animId = 'http://www.roblox.com/Asset?ID=' .. animations[input.KeyCode]
            if animId ~= currentAnimId then
                if humanoid ~= nil and humanoid.Health > 0 then
                    if currentPlaying ~= nil and currentPlaying.IsPlaying then
                        currentPlaying:Stop()
                    end
                    local animation = Instance.new('Animation'); animation.AnimationId = animId
                    local animTrack = humanoid:LoadAnimation(animation); currentPlaying = animTrack
                    animTrack:Play(0.100000001,1,1)
                end
            end
        end
    end
end)
0
Yes, before you ask, the script is free modeled, I just wanted an animation script, and I have no idea how to make one myself. ExcelUp 24 — 6y
0
Did you put it in a local script in somewhere like StarterPack or StarterGui? mattscy 3725 — 6y
0
Is the game FE? SebbyTheGODKid 198 — 6y

Answer this question