Facebook
From local plr = game.Players.LocalPl, 3 Years ago, written in Lua.
This paste is a reply to Animation showcase script from OfficiallySpo_oky - go back
Embed
--Created by SoloCord#7142 (the script is a little rough, I know)

--This is for animators applying for the role and don't know how to play an animation.
--This is a copy and paste, only edit stuff in the settings

--THIS IS A LOCAL SCRIPT, PLACE IN STARTER GUI

--HOW TO PROPERLY SETUP
--[[
        Create a folder named "Animations"
        Place the folder in Workspace
        For EACH ANIMATION you have make a new animation, name does not matter.
        For EACH animation please put the correct animation id
]]

local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local ws = game:GetService("Workspace")
local animationFolder = ws:FindFirstChild("Animations")

local function setup()
        local screenUI = Instance.new("ScreenGui")
        screenUI.Name = "AnimationsHandler"
        screenUI.Parent = plrGui
        
        local frameBg = Instance.new("Frame")
        frameBg.Size = UDim2.new(0.2, 0, 0.6, 0)
        frameBg.Position = UDim2.new(.005, 0, .305, 0)
        frameBg.BackgroundTransparency = 1
        frameBg.ZIndex = 100
        frameBg.Parent = screenUI
        
        local UIGL = Instance.new("UIGridLayout")
        UIGL.CellSize = UDim2.new(1, 0, .1, 0)
        UIGL.Parent = frameBg
end

local function createButtons(amountOfAnimations)
        local frameBackground = plrGui:WaitForChild("AnimationsHandler"):WaitForChild("Frame")
        for i = 1, #amountOfAnimations do
                local button = Instance.new("TextButton")
                button.Text = "Animation: "..amountOfAnimations[i].AnimationId
                button.Parent = frameBackground
                
                local animation = Instance.new("Animation")
                animation.AnimationId = amountOfAnimations[i].AnimationId
                animation.Parent = button
        end
        return true
end

local function manageButtons()
        local frameBackground = plrGui:WaitForChild("AnimationsHandler"):WaitForChild("Frame")
        for i, v in pairs(frameBackground:GetChildren()) do
                if v:IsA("TextButton") then
                        v.MouseButton1Down:Connect(function()
                                local animation = plr.Character.Humanoid:LoadAnimation(v.Animation)
                                if animation then
                                        print(1)
                                        animation:Play()
                                        print(2)
                                end
                        end)
                end
        end
end

if animationFolder ~= nil then
        local amountOfAnimations = animationFolder:GetChildren()
        setup()
        if createButtons(amountOfAnimations) then
                manageButtons()
        end
else
        error("Improperly set up. Please make sure to put a folder named 'Animations' in workspace")
end