SHARE
TWEET

Untitled

a guest Jun 27th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This script has been converted to FE by iPxter
  2.  
  3.  
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  6. do
  7.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  8.     script.Parent = Player.Character
  9.  
  10.     --RemoteEvent for communicating
  11.     local Event = Instance.new("RemoteEvent")
  12.     Event.Name = "UserInput_Event"
  13.  
  14.     --Fake event to make stuff like Mouse.KeyDown work
  15.     local function fakeEvent()
  16.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  17.         t.connect = t.Connect
  18.         return t
  19.     end
  20.  
  21.     --Creating fake input objects with fake variables
  22.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26.     end}
  27.     --Merged 2 functions into one by checking amount of arguments
  28.     CAS.UnbindAction = CAS.BindAction
  29.  
  30.     --This function will trigger the events that have been :Connect()'ed
  31.     local function te(self,ev,...)
  32.         local t = m[ev]
  33.         if t and t._fakeEvent and t.Function then
  34.             t.Function(...)
  35.         end
  36.     end
  37.     m.TrigEvent = te
  38.     UIS.TrigEvent = te
  39.  
  40.     Event.OnServerEvent:Connect(function(plr,io)
  41.         if plr~=Player then return end
  42.         if io.isMouse then
  43.             m.Target = io.Target
  44.             m.Hit = io.Hit
  45.         else
  46.             local b = io.UserInputState == Enum.UserInputState.Begin
  47.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49.             end
  50.             for _,t in pairs(CAS.Actions) do
  51.                 for _,k in pairs(t.Keys) do
  52.                     if k==io.KeyCode then
  53.                         t.Function(t.Name,io.UserInputState,io)
  54.                     end
  55.                 end
  56.             end
  57.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59.         end
  60.     end)
  61.     Event.Parent = NLS([==[
  62.     local Player = game:GetService("Players").LocalPlayer
  63.     local Event = script:WaitForChild("UserInput_Event")
  64.  
  65.     local UIS = game:GetService("UserInputService")
  66.     local input = function(io,a)
  67.         if a then return end
  68.         --Since InputObject is a client-side instance, we create and pass table instead
  69.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  70.     end
  71.     UIS.InputBegan:Connect(input)
  72.     UIS.InputEnded:Connect(input)
  73.  
  74.     local Mouse = Player:GetMouse()
  75.     local h,t
  76.     --Give the server mouse data 30 times every second, but only if the values changed
  77.     --If player is not moving their mouse, client won't fire events
  78.     while wait(1/30) do
  79.         if h~=Mouse.Hit or t~=Mouse.Target then
  80.             h,t=Mouse.Hit,Mouse.Target
  81.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  82.         end
  83.     end]==],Player.Character)
  84.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  85. end
  86.  
  87.  
  88.  
  89.  
  90.  
  91. print 'RUSSIAN DANCE BY LYKASPARS4! HAS BEEN RUNNED!'
  92. print 'SOUND:YES'
  93. print 'ANIMATION:YES'
  94.  
  95. local s = Instance.new("Sound")
  96.  
  97. s.Name = "Sound"
  98. s.SoundId = "http://www.roblox.com/asset/?id=169566828"
  99. s.Volume = 1
  100. s.Looped = true
  101. s.archivable = false
  102.  
  103. s.Parent = game.Workspace
  104.  
  105. wait(3)
  106.  
  107. s:play()
  108.  
  109. function   waitForChild(parent, childName)
  110.     local child = parent:findFirstChild(childName)
  111.     if child then return child end
  112.     while true do
  113.         child = parent.ChildAdded:wait()
  114.         if child.Name==childName then return child end
  115.     end
  116. end
  117.  
  118. local Figure = script.Parent
  119. local Torso = waitForChild(Figure, "Torso")
  120. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  121. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  122. local RightHip = waitForChild(Torso, "Right Hip")
  123. local LeftHip = waitForChild(Torso, "Left Hip")
  124. local Neck = waitForChild(Torso, "Neck")
  125. local Humanoid = waitForChild(Figure, "Humanoid")
  126. local pose = "Standing"
  127.  
  128. local currentAnim = ""
  129. local currentAnimTrack = nil
  130. local currentAnimKeyframeHandler = nil
  131. local currentAnimSpeed = 1.0
  132. local oldAnimTrack = nil
  133. local animTable = {}
  134. local animNames = {
  135.     idle =  {  
  136.                 { id = "rbxassetid://125750544", weight = 9 },
  137.                 { id = "rbxassetid://125750618", weight = 1 }
  138.             },
  139.     walk =  {  
  140.                 { id = "rbxassetid://125749145", weight = 10 }
  141.             },
  142.     run =   {
  143.                 { id = "run.xml", weight = 10 }
  144.             },
  145.     jump =  {
  146.                 { id = "rbxassetid://125750702", weight = 10 }
  147.             },
  148.     fall =  {
  149.                 { id = "rbxassetid://125750759", weight = 10 }
  150.             },
  151.     climb = {
  152.                 { id = "rbxassetid://125750800", weight = 10 }
  153.             },
  154.     toolnone = {
  155.                 { id = "rbxassetid://125750867", weight = 10 }
  156.             },
  157.     toolslash = {
  158.                 { id = "rbxassetid://129967390", weight = 10 }
  159. --              { id = "slash.xml", weight = 10 }
  160.             },
  161.     toollunge = {
  162.                 { id = "rbxassetid://129967478", weight = 10 }
  163.             },
  164.     wave = {
  165.                 { id = "rbxassetid://128777973", weight = 10 }
  166.             },
  167.     point = {
  168.                 { id = "rbxassetid://128853357", weight = 10 }
  169.             },
  170.     dance = {
  171.                 { id = "rbxassetid://130018893", weight = 10 },
  172.                 { id = "rbxassetid://132546839", weight = 10 },
  173.                 { id = "rbxassetid://132546884", weight = 10 }
  174.             },
  175.     laugh = {
  176.                 { id = "rbxassetid://129423131", weight = 10 }
  177.             },
  178.     cheer = {
  179.                 { id = "rbxassetid://=129423030", weight = 10 }
  180.             },
  181. }
  182.  
  183. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  184. local emoteNames = { wave = false, point = false, dance = true, laugh = false, cheer = false}
  185.  
  186. math.randomseed(tick())
  187.  
  188. -- Setup animation objects
  189. for name, fileList in pairs(animNames) do
  190.     animTable[name] = {}
  191.     animTable[name].count = 0
  192.     animTable[name].totalWeight = 0
  193.  
  194.     -- check for config values
  195.     local config = script:FindFirstChild(name)
  196.     if (config ~= nil) then
  197. --      print("Loading anims " .. name)
  198.         local idx = 1
  199.         for _, childPart in pairs(config:GetChildren()) do
  200.             animTable[name][idx] = {}
  201.             animTable[name][idx].anim = childPart
  202.             local weightObject = childPart:FindFirstChild("Weight")
  203.             if (weightObject == nil) then
  204.                 animTable[name][idx].weight = 1
  205.             else
  206.                 animTable[name][idx].weight = weightObject.Value
  207.             end
  208.             animTable[name].count = animTable[name].count + 1
  209.             animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  210. --          print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  211.             idx = idx + 1
  212.         end
  213.     end
  214.  
  215.     -- fallback to defaults
  216.     if (animTable[name].count <= 0) then
  217.         for idx, anim in pairs(fileList) do
  218.             animTable[name][idx] = {}
  219.             animTable[name][idx].anim = Instance.new("Animation")
  220.             animTable[name][idx].anim.Name = name
  221.             animTable[name][idx].anim.AnimationId = anim.id
  222.             animTable[name][idx].weight = anim.weight
  223.             animTable[name].count = animTable[name].count + 1
  224.             animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  225. --          print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  226.         end
  227.     end
  228. end
  229.  
  230. -- ANIMATION
  231.  
  232. -- declarations
  233. local toolAnim = "None"
  234. local toolAnimTime = 0
  235.  
  236. local jumpAnimTime = 0
  237. local jumpAnimDuration = 0.175
  238.  
  239. local toolTransitionTime = 0.1
  240. local fallTransitionTime = 0.2
  241. local jumpMaxLimbVelocity = 0.75
  242.  
  243. -- functions
  244.  
  245. function stopAllAnimations()
  246.     local oldAnim = currentAnim
  247.  
  248.     -- return to idle if finishing an emote
  249.     if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  250.         oldAnim = "idle"
  251.     end
  252.  
  253.     currentAnim = ""
  254.     if (currentAnimKeyframeHandler ~= nil) then
  255.         currentAnimKeyframeHandler:disconnect()
  256.     end
  257.  
  258.     if (oldAnimTrack ~= nil) then
  259.         oldAnimTrack:Stop()
  260.         oldAnimTrack:Destroy()
  261.         oldAnimTrack = nil
  262.     end
  263.     if (currentAnimTrack ~= nil) then
  264.         currentAnimTrack:Stop()
  265.         currentAnimTrack:Destroy()
  266.         currentAnimTrack = nil
  267.     end
  268.     return oldAnim
  269. end
  270.  
  271. function setAnimationSpeed(speed)
  272.     if speed ~= currentAnimSpeed then
  273.         currentAnimSpeed = speed
  274.         currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  275.     end
  276. end
  277.  
  278. function keyFrameReachedFunc(frameName)
  279.     if (frameName == "End") then
  280. --      print("Keyframe : ".. frameName)
  281.         local repeatAnim = stopAllAnimations()
  282.         local animSpeed = currentAnimSpeed
  283.         playAnimation(repeatAnim, 0.0, Humanoid)
  284.         setAnimationSpeed(animSpeed)
  285.     end
  286. end
  287.  
  288. -- Preload animations
  289. function playAnimation(animName, transitionTime, humanoid)
  290.     if (animName ~= currentAnim) then        
  291.        
  292.         if (oldAnimTrack ~= nil) then
  293.             oldAnimTrack:Stop()
  294.             oldAnimTrack:Destroy()
  295.         end
  296.  
  297.         currentAnimSpeed = 1.0
  298.         local roll = math.random(1, animTable[animName].totalWeight)
  299.         local origRoll = roll
  300.         local idx = 1
  301.         while (roll > animTable[animName][idx].weight) do
  302.             roll = roll - animTable[animName][idx].weight
  303.             idx = idx + 1
  304.         end
  305. --      print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  306.         local anim = animTable[animName][idx].anim
  307.  
  308.         -- load it to the humanoid; get AnimationTrack
  309.         oldAnimTrack = currentAnimTrack
  310.         currentAnimTrack = humanoid:LoadAnimation(anim)
  311.          
  312.         -- play the animation
  313.         currentAnimTrack:Play(transitionTime)
  314.         currentAnim = animName
  315.  
  316.         -- set up keyframe name triggers
  317.         if (currentAnimKeyframeHandler ~= nil) then
  318.             currentAnimKeyframeHandler:disconnect()
  319.         end
  320.         currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  321.     end
  322. end
  323.  
  324. -------------------------------------------------------------------------------------------
  325. -------------------------------------------------------------------------------------------
  326.  
  327. local toolAnimName = ""
  328. local toolOldAnimTrack = nil
  329. local toolAnimTrack = nil
  330. local currentToolAnimKeyframeHandler = nil
  331.  
  332. function toolKeyFrameReachedFunc(frameName)
  333.     if (frameName == "End") then
  334. --      print("Keyframe : ".. frameName)
  335.         local repeatAnim = stopToolAnimations()
  336.         playToolAnimation(repeatAnim, 0.0, Humanoid)
  337.     end
  338. end
  339.  
  340.  
  341. function playToolAnimation(animName, transitionTime, humanoid)
  342.     if (animName ~= toolAnimName) then       
  343.        
  344.         if (toolAnimTrack ~= nil) then
  345.             toolAnimTrack:Stop()
  346.             toolAnimTrack:Destroy()
  347.             transitionTime = 0
  348.         end
  349.  
  350.         local roll = math.random(1, animTable[animName].totalWeight)
  351.         local origRoll = roll
  352.         local idx = 1
  353.         while (roll > animTable[animName][idx].weight) do
  354.             roll = roll - animTable[animName][idx].weight
  355.             idx = idx + 1
  356.         end
  357. --      print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  358.         local anim = animTable[animName][idx].anim
  359.  
  360.         -- load it to the humanoid; get AnimationTrack
  361.         toolOldAnimTrack = toolAnimTrack
  362.         toolAnimTrack = humanoid:LoadAnimation(anim)
  363.          
  364.         -- play the animation
  365.         toolAnimTrack:Play(transitionTime)
  366.         toolAnimName = animName
  367.  
  368.         currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  369.     end
  370. end
  371.  
  372. function stopToolAnimations()
  373.     local oldAnim = toolAnimName
  374.  
  375.     if (currentToolAnimKeyframeHandler ~= nil) then
  376.         currentToolAnimKeyframeHandler:disconnect()
  377.     end
  378.  
  379.     toolAnimName = ""
  380.     if (toolAnimTrack ~= nil) then
  381.         toolAnimTrack:Stop()
  382.         toolAnimTrack:Destroy()
  383.         toolAnimTrack = nil
  384.     end
  385.  
  386.  
  387.     return oldAnim
  388. end
  389.  
  390. -------------------------------------------------------------------------------------------
  391. -------------------------------------------------------------------------------------------
  392.  
  393.  
  394. function onRunning(speed)
  395.     if speed>0 then
  396.         playAnimation("walk", 0.1, Humanoid)
  397.         pose = "Running"
  398.     else
  399.         playAnimation("idle", 0.1, Humanoid)
  400.         pose = "Standing"
  401.     end
  402. end
  403.  
  404. function onDied()
  405.     pose = "Dead"
  406. end
  407.  
  408. function onJumping()
  409.     playAnimation("jump", 0.1, Humanoid)
  410.     jumpAnimTime = jumpAnimDuration
  411.     pose = "Jumping"
  412. end
  413.  
  414. function onClimbing(speed)
  415.     playAnimation("climb", 0.1, Humanoid)
  416.     setAnimationSpeed(speed / 12.0)
  417.     pose = "Climbing"
  418. end
  419.  
  420. function onGettingUp()
  421.     pose = "GettingUp"
  422. end
  423.  
  424. function onFreeFall()
  425.     if (jumpAnimTime <= 0) then
  426.         playAnimation("fall", fallTransitionTime, Humanoid)
  427.     end
  428.     pose = "FreeFall"
  429. end
  430.  
  431. function onFallingDown()
  432.     pose = "FallingDown"
  433. end
  434.  
  435. function onSeated()
  436.     pose = "Seated"
  437. end
  438.  
  439. function onPlatformStanding()
  440.     pose = "PlatformStanding"
  441. end
  442.  
  443. function onSwimming(speed)
  444.     if speed>0 then
  445.         pose = "Running"
  446.     else
  447.         pose = "Standing"
  448.     end
  449. end
  450.  
  451. function getTool() 
  452.     for _, kid in ipairs(Figure:GetChildren()) do
  453.         if kid.className == "Tool" then return kid end
  454.     end
  455.     return nil
  456. end
  457.  
  458. function getToolAnim(tool)
  459.     for _, c in ipairs(tool:GetChildren()) do
  460.         if c.Name == "toolanim" and c.className == "StringValue" then
  461.             return c
  462.         end
  463.     end
  464.     return nil
  465. end
  466.  
  467. function animateTool()
  468.    
  469.     if (toolAnim == "None") then
  470.         playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  471.         return
  472.     end
  473.  
  474.     if (toolAnim == "Slash") then
  475.         playToolAnimation("toolslash", 0, Humanoid)
  476.         return
  477.     end
  478.  
  479.     if (toolAnim == "Lunge") then
  480.         playToolAnimation("toollunge", 0, Humanoid)
  481.         return
  482.     end
  483. end
  484.  
  485. function moveSit()
  486.     RightShoulder.MaxVelocity = 0.15
  487.     LeftShoulder.MaxVelocity = 0.15
  488.     RightShoulder:SetDesiredAngle(3.14 /2)
  489.     LeftShoulder:SetDesiredAngle(-3.14 /2)
  490.     RightHip:SetDesiredAngle(3.14 /2)
  491.     LeftHip:SetDesiredAngle(-3.14 /2)
  492. end
  493.  
  494. local lastTick = 0
  495.  
  496. function move(time)
  497.     local amplitude = 1
  498.     local frequency = 1
  499.     local deltaTime = time - lastTick
  500.     lastTick = time
  501.  
  502.     local climbFudge = 0
  503.     local setAngles = false
  504.  
  505.     if (jumpAnimTime > 0) then
  506.         jumpAnimTime = jumpAnimTime - deltaTime
  507.     end
  508.  
  509.     if (pose == "FreeFall" and jumpAnimTime <= 0) then
  510.         playAnimation("fall", fallTransitionTime, Humanoid)
  511.     elseif (pose == "Seated") then
  512.         stopAllAnimations()
  513.         moveSit()
  514.         return
  515.     elseif (pose == "Running") then
  516.         playAnimation("walk", 0.1, Humanoid)
  517.     elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  518. --      print("Wha " .. pose)
  519.         amplitude = 0.1
  520.         frequency = 1
  521.         setAngles = true
  522.     end
  523.  
  524.     if (setAngles) then
  525.         desiredAngle = amplitude * math.sin(time * frequency)
  526.  
  527.         RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  528.         LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  529.         RightHip:SetDesiredAngle(-desiredAngle)
  530.         LeftHip:SetDesiredAngle(-desiredAngle)
  531.     end
  532.  
  533.     -- Tool Animation handling
  534.     local tool = getTool()
  535.     if tool then
  536.    
  537.         animStringValueObject = getToolAnim(tool)
  538.  
  539.         if animStringValueObject then
  540.             toolAnim = animStringValueObject.Value
  541.             -- message recieved, delete StringValue
  542.             animStringValueObject.Parent = nil
  543.             toolAnimTime = time + .3
  544.         end
  545.  
  546.         if time > toolAnimTime then
  547.             toolAnimTime = 0
  548.             toolAnim = "None"
  549.         end
  550.  
  551.         animateTool()      
  552.     else
  553.         stopToolAnimations()
  554.         toolAnim = "None"
  555.         toolAnimTime = 0
  556.     end
  557. end
  558.  
  559. -- connect events
  560. Humanoid.Died:connect(onDied)
  561. Humanoid.Running:connect(onRunning)
  562. Humanoid.Jumping:connect(onJumping)
  563. Humanoid.Climbing:connect(onClimbing)
  564. Humanoid.GettingUp:connect(onGettingUp)
  565. Humanoid.FreeFalling:connect(onFreeFall)
  566. Humanoid.FallingDown:connect(onFallingDown)
  567. Humanoid.Seated:connect(onSeated)
  568. Humanoid.PlatformStanding:connect(onPlatformStanding)
  569. Humanoid.Swimming:connect(onSwimming)
  570.  
  571. -- setup emote chat hook
  572. Game.Players.LocalPlayer.Chatted:connect(function(msg)
  573.     local emote = ""
  574.     if (string.sub(msg, 1, 3) == "/e ") then
  575.         emote = string.sub(msg, 4)
  576.     elseif (string.sub(msg, 1, 7) == "/emote ") then
  577.         emote = string.sub(msg, 8)
  578.     end
  579.    
  580.     if (pose == "Standing" and emoteNames[emote] ~= nil) then
  581.         playAnimation(emote, 0.1, Humanoid)
  582.     end
  583. --  print("===> " .. string.sub(msg, 1, 3) .. "(" .. emote .. ")")
  584. end)
  585.  
  586.  
  587. -- main program
  588.  
  589. local runService = game:service("RunService");
  590.  
  591. -- initialize to idle
  592. playAnimation("idle", 0.1, Humanoid)
  593. pose = "Standing"
  594.  
  595. while Figure.Parent~=nil do
  596.     local _, time = wait(0.1)
  597.     move(time)
  598. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top