Advertisement
ItsSp0oky

AR Animation Application script

May 5th, 2021
3,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. --Created by SoloCord#7142 (the script is a little rough, I know)
  2.  
  3. --This is for animators applying for the role and don't know how to play an animation.
  4. --This is a copy and paste, only edit stuff in the settings
  5.  
  6. --THIS IS A LOCAL SCRIPT, PLACE IN STARTER GUI
  7.  
  8. --HOW TO PROPERLY SETUP
  9. --[[
  10. Create a folder named "Animations"
  11. Place the folder in Workspace
  12. For EACH ANIMATION you have make a new animation, name does not matter.
  13. For EACH animation please put the correct animation id
  14. ]]
  15.  
  16. local plr = game.Players.LocalPlayer
  17. local plrGui = plr:WaitForChild("PlayerGui")
  18.  
  19. local ws = game:GetService("Workspace")
  20. local animationFolder = ws:FindFirstChild("Animations")
  21.  
  22. local function setup()
  23. local screenUI = Instance.new("ScreenGui")
  24. screenUI.Name = "AnimationsHandler"
  25. screenUI.Parent = plrGui
  26.  
  27. local frameBg = Instance.new("Frame")
  28. frameBg.Size = UDim2.new(0.2, 0, 0.6, 0)
  29. frameBg.Position = UDim2.new(.005, 0, .305, 0)
  30. frameBg.BackgroundTransparency = 1
  31. frameBg.ZIndex = 100
  32. frameBg.Parent = screenUI
  33.  
  34. local UIGL = Instance.new("UIGridLayout")
  35. UIGL.CellSize = UDim2.new(1, 0, .1, 0)
  36. UIGL.Parent = frameBg
  37. end
  38.  
  39. local function createButtons(amountOfAnimations)
  40. local frameBackground = plrGui:WaitForChild("AnimationsHandler"):WaitForChild("Frame")
  41. for i = 1, #amountOfAnimations do
  42. local button = Instance.new("TextButton")
  43. button.Text = "Animation: "..amountOfAnimations[i].AnimationId
  44. button.Parent = frameBackground
  45.  
  46. local animation = Instance.new("Animation")
  47. animation.AnimationId = amountOfAnimations[i].AnimationId
  48. animation.Parent = button
  49. end
  50. return true
  51. end
  52.  
  53. local function manageButtons()
  54. local frameBackground = plrGui:WaitForChild("AnimationsHandler"):WaitForChild("Frame")
  55. for i, v in pairs(frameBackground:GetChildren()) do
  56. if v:IsA("TextButton") then
  57. v.MouseButton1Down:Connect(function()
  58. local animation = plr.Character.Humanoid:LoadAnimation(v.Animation)
  59. if animation then
  60. print(1)
  61. animation:Play()
  62. print(2)
  63. end
  64. end)
  65. end
  66. end
  67. end
  68.  
  69. if animationFolder ~= nil then
  70. local amountOfAnimations = animationFolder:GetChildren()
  71. setup()
  72. if createButtons(amountOfAnimations) then
  73. manageButtons()
  74. end
  75. else
  76. error("Improperly set up. Please make sure to put a folder named 'Animations' in workspace")
  77. end
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement