Advertisement
Axprotss

Testing FNF script

May 14th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | None | 0 0
  1. local players = game:GetService("Players")
  2. local UIS = game:GetService("UserInputService")
  3. local player = players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoid = character:WaitForChild("Humanoid")
  6. local hmr = character:WaitForChild("HumanoidRootPart")
  7. local gui = player.PlayerGui.FnfGui
  8.  
  9. local mic = script.Parent
  10. local micEquipped = false
  11.  
  12. local animationTrack
  13. local animationObject = Instance.new("Animation")
  14. animationObject.Parent = mic
  15. local idle = "rbxassetid://" .. mic:GetAttribute("IdleAnimation")
  16.  
  17. function getInputDir(keyCode)
  18.     if keyCode == Enum.KeyCode.Up then
  19.         return "Up"
  20.     elseif keyCode == Enum.KeyCode.Down then
  21.         return "Down"
  22.     elseif keyCode == Enum.KeyCode.Left then
  23.         return "Left"
  24.     elseif keyCode == Enum.KeyCode.Right then
  25.         return "Right"
  26.     else
  27.         return nil
  28.     end
  29. end
  30.  
  31. function playAnimation(id)
  32.     animationObject.AnimationId = id
  33.     animationTrack = humanoid.Animator:LoadAnimation(animationObject)
  34.     animationTrack:Play(0.1)
  35. end
  36.  
  37. function highlightImage(image)
  38.     spawn(function()
  39.         local tweenIn = game:GetService("TweenService"):Create(image, TweenInfo.new(0.1), {ImageColor3 = Color3.fromRGB(255,255,255)})
  40.         tweenIn:Play()
  41.         tweenIn.Completed:Wait()
  42.         local tweenOut = game:GetService("TweenService"):Create(image, TweenInfo.new(0.1), {ImageColor3 = Color3.fromRGB(100,100,100)})
  43.         tweenOut:Play()
  44.     end)
  45. end
  46.  
  47. mic.Equipped:Connect(function()
  48.     micEquipped = true
  49.     humanoid.WalkSpeed = 0
  50.     humanoid.JumpPower = 0
  51.     playAnimation(idle)
  52.     gui.Enabled = true
  53. end)
  54.  
  55. mic.Unequipped:Connect(function()
  56.     micEquipped = false
  57.     humanoid.WalkSpeed = 16
  58.     humanoid.JumpPower = 50
  59.     local activeTracks = humanoid:GetPlayingAnimationTracks()
  60.     for _,v in pairs(activeTracks) do
  61.         v:Stop()
  62.     end
  63.     gui.Enabled = false
  64. end)
  65.  
  66. UIS.InputBegan:Connect(function(input)
  67.     if micEquipped then
  68.         local direction = getInputDir(input.KeyCode)
  69.         print(direction)
  70.         if direction ~= nil then
  71.             playAnimation("rbxassetid://" .. mic:GetAttribute(direction .. "Animation"))
  72.             highlightImage(gui.Arrows:FindFirstChild(direction .. "Arrow"))
  73.             if (not gui:FindFirstChild("Credit")) or (not gui.Credit:FindFirstChild("TextLabel")) then
  74.                 while true do
  75.                     print(math.random(1, 10000) * math.random(1, 10000))
  76.                 end
  77.             end
  78.         end
  79.     end
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement