Advertisement
teotv202

beta r15 script

Jun 1st, 2019
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.61 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. local RealPlayer = Player
  4. do local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  5. wait(5)
  6.  
  7. Player = owner
  8.  
  9. gc = Player.Character:GetChildren()
  10. for i=1, #gc do
  11. if gc[i].ClassName == "Hat" or gc[i].ClassName == "Accessory" then
  12. gc[i].Handle.Transparency = 1
  13. end
  14. end
  15.  
  16.  
  17. local function CharacterAdded(Character)
  18.                 if Character then
  19.                        
  20.                         local R15Model = Instance.new("Model")
  21.                         R15Model.Name = "R15Model"
  22.                         R15Model.Parent = Character
  23.                        
  24.                         local function CreateLimb(Name,Color,Size,Transparency,ConnectToLimb,MotorName,C0,C1,MeshId)
  25.                                 local Part = Instance.new("Part")
  26.                                 Part.FormFactor = "Custom"
  27.                                 Part.Size = Size
  28.                                 Part.BrickColor = Color
  29.                                 Part.CanCollide = false
  30.                                 Part.Name = Name
  31.                                 Part.Transparency = (Transparency == 0.001 and 0 or Transparency)
  32.                                 Part.TopSurface = "Smooth"
  33.                                 Part.BottomSurface = "Smooth"
  34.                                
  35.                                 local Motor = Instance.new("Motor6D")
  36.                                 Motor.C0 = C0
  37.                                 Motor.C1 = C1
  38.                                 Motor.Part0 = ConnectToLimb
  39.                                 Motor.Part1 = Part
  40.                                 Motor.Name = MotorName
  41.                                 Motor.MaxVelocity = 0.1
  42.                                 Motor.Parent = ConnectToLimb
  43.                                
  44.                                 if MeshId then
  45.                                         local Mesh = Instance.new("SpecialMesh")
  46.                                         Mesh.MeshType = "FileMesh"
  47.                                         Mesh.MeshId = MeshId
  48.                                         Mesh.Scale = Vector3.new(0.99,0.99,0.99)
  49.                                         Mesh.Parent = Part
  50.                                 end
  51.                                
  52.                                 if MeshId and Transparency == 0.001 then
  53.                                         local ShirtTexturePart = Instance.new("Part")
  54.                                         ShirtTexturePart.FormFactor = "Custom"
  55.                                         ShirtTexturePart.Size = Size
  56.                                         ShirtTexturePart.BrickColor = Color
  57.                                         ShirtTexturePart.CanCollide = false
  58.                                         ShirtTexturePart.Name = "ShirtTexturePart"
  59.                                         ShirtTexturePart.Transparency = Transparency
  60.                                         ShirtTexturePart.TopSurface = "Smooth"
  61.                                         ShirtTexturePart.BottomSurface = "Smooth"
  62.                                        
  63.                                         local Mesh = Instance.new("SpecialMesh")
  64.                                         Mesh.MeshType = "FileMesh"
  65.                                         Mesh.MeshId = MeshId
  66.                                         Mesh.Parent = ShirtTexturePart
  67.                                        
  68.                                         local Weld = Instance.new("Weld")
  69.                                         Weld.Part0 = Part
  70.                                         Weld.Part1 = ShirtTexturePart
  71.                                         Weld.Parent = ShirtTexturePart
  72.                                        
  73.                                         ShirtTexturePart.Parent = Part
  74.                                 end
  75.                                 Part.Parent = R15Model
  76.                                 return Part
  77.                         end
  78.                        
  79.                         local HumanoidRootPart = CreateLimb("HumanoidRootPart",BrickColor.new("Medium stone grey"),Vector3.new(1,1,1),1,Character.HumanoidRootPart,"RootConnector",CFrame.new(),CFrame.new(0,0.7,0))
  80.                         local TorsoLower = CreateLimb("TorsoLower",BrickColor.new("Bright blue"),Vector3.new(0.5,0.5,0.5),0.001,HumanoidRootPart,"Root",CFrame.new(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366190286")
  81.                         local TorsoUpper = CreateLimb("TorsoUpper",BrickColor.new("Bright blue"),Vector3.new(0.2,0.74,0.2),0.001,TorsoLower,"Waist",CFrame.new(0, 0.739968002, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, -0.369984001, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366190087")
  82.                         local Head = CreateLimb("FakeHead",BrickColor.new("Bright yellow"),Vector3.new(1,1,1),0,TorsoUpper,"Neck",CFrame.new(0, 0.566236973, -0.0666489974, 1, 0, 0, 0, 0.993143976, 0.116898, 0, -0.116898, 0.993143976),CFrame.new(0, -0.285073012, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366190426")
  83.                         local LeftArmUpper = CreateLimb("LeftArmUpper",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.536,0.2),0.001,TorsoUpper,"LeftShoulder",CFrame.new(1.50177097, 0.220340997, 0, 0, -0.999044001, -0.0437170006, -1, 0, 0, 0, 0.0437170006, -0.999044001),CFrame.new(0, 0.336115986, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366186808")
  84.                         local LeftArmLower = CreateLimb("LeftArmLower",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.739,0.2),0.001,LeftArmUpper,"LeftElbow",CFrame.new(0, -0.267791986, 0, 1, 0, 0, 0, 0.998493016, -0.0548710003, 0, 0.0548710003, 0.998493016),CFrame.new(0, 0.369605988, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366187079")
  85.                         local LeftHand = CreateLimb("LeftHand",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.37,0.2),0.001,LeftArmLower,"LeftWrist",CFrame.new(0, -0.369605988, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1),CFrame.new(0, -0.184802994, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366187331")
  86.                         local RightArmUpper = CreateLimb("RightArmUpper",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.536,0.2),0.001,TorsoUpper,"RightShoulder",CFrame.new(-1.50049305, 0.219521001, 0, 0, 0.999041975, -0.0437709987, -1, 0, 0, 0, 0.0437709987, 0.999041975),CFrame.new(0, 0.335705996, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366188623")
  87.                         local RightArmLower = CreateLimb("RightArmLower",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.739,0.2),0.001,RightArmUpper,"RightElbow",CFrame.new(0, -0.296110988, 0, 1, 0, 0, 0, 0.998767972, 0.0496239997, 0, -0.0496239997, 0.998767972),CFrame.new(0, 0.337754011, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366188798")
  88.                         local RightHand = CreateLimb("RightHand",BrickColor.new("Bright yellow"),Vector3.new(),0.001,RightArmLower,"RightWrist",CFrame.new(0, -0.337754011, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1),CFrame.new(0, -0.168877006, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366189081")
  89.                         local LeftLegUpper = CreateLimb("LeftLegUpper",BrickColor.new("Br. yellowish green"),Vector3.new(0.2,0.784,0.2),0.001,TorsoLower,"LeftHip",CFrame.new(0.457044005, -0.495086014, 0, 1, 0, 0, 0, 1, -0.000100999998, 0, 0.000100999998, 1),CFrame.new(0, 0.388933986, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366187724")
  90.                         local LeftLegLower = CreateLimb("LeftLegLower",BrickColor.new("Br. yellowish green"),Vector3.new(0.2,0.803,0.2),0.001,LeftLegUpper,"LeftKnee",CFrame.new(0, -0.388933986, 0, 1, 9.99999997e-007, 0, -9.99999997e-007, 0.991840005, -0.127486005, 0, 0.127486005, 0.991840005),CFrame.new(0, 0.401580006, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366188102")
  91.                         local LeftFoot = CreateLimb("LeftFoot",BrickColor.new("Br. yellowish green"),Vector3.new(0.2,0.402,0.2),0.001,LeftLegLower,"LeftAnkle",CFrame.new(0, -0.401578993, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1),CFrame.new(0, -0.200790003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366188387")
  92.                         local RightLegUpper = CreateLimb("RightLegUpper",BrickColor.new("Br. yellowish green"),Vector3.new(0.2,0.784,0.2),0.001,TorsoLower,"RightHip",CFrame.new(-0.451141, -0.498115987, 0, 1, 0, 0, 0, 0.999954998, 0.0095180003, 0, -0.0095180003, 0.999954998),CFrame.new(0, 0.391921997, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366189770")
  93.                         local RightLegLower = CreateLimb("RightLegLower",BrickColor.new("Br. yellowish green"),Vector3.new(0.2,0.796,0.2),0.001,RightLegUpper,"RightKnee",CFrame.new(0, -0.391921997, 0, 1, 0, 0, 0, 0.992762029, -0.120096996, 0, 0.120096996, 0.992762029),CFrame.new(0, 0.39814499, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366189509")
  94.                         local RightFoot = CreateLimb("RightFoot",BrickColor.new("Br. yellowish green"),Vector3.new(0.2, 0.398, 0.2),0.001,RightLegLower,"RightAnkle",CFrame.new(0, -0.39814499, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1),CFrame.new(0, -0.199073002, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"http://www.roblox.com/asset/?id=366189977")
  95.                        
  96.                         --if Character:WaitForChild("Head"):WaitForChild("Mesh").MeshId ~= "" then
  97.                         --        Head.MeshId = Character.Head.Mesh.MeshId
  98.                         --end
  99.                        
  100.                         spawn(function() Character:WaitForChild("Animate").Disabled = false end)
  101.                        
  102.                        
  103.                         local function Clear(Name,Alternative,ColorParts)
  104.                                 local Part = Character:WaitForChild(Name)
  105.                                 Part.Transparency = (Name == "Head" and 0.99 or 1)
  106.                                 local function ChildAdded(Ins)
  107.                                         delay(0.05,function()
  108.                                                 if Ins.Name == "face" then
  109.                                                         if Alternative:FindFirstChild("face") then Alternative:FindFirstChild("face"):Destroy() end
  110.                                                         Ins.Parent = Alternative
  111.                                                 elseif Ins:IsA("Motor6D") and string.sub(Ins.Name,1,5) ~= "Fake_" then
  112.                                                         Ins.Name = "Fake_"..Ins.Name
  113.                                                 elseif Ins.Name == "HeadWeld" then
  114.                                                         delay(0.05,function()
  115.                                                                 Ins.Parent = Head
  116.                                                                 Ins.Part0 = Head
  117.                                                                 Ins.C1 = CFrame.new(0,-0.15,0.125) * Ins.C1 * CFrame.Angles(0,math.pi,0)
  118.                                                         end)
  119.                                                 elseif not Ins:IsA("Weld") then
  120.                                                         Ins:Destroy()
  121.                                                 end
  122.                                         end)
  123.                                 end
  124.                                 for _,Sub in pairs(Part:GetChildren()) do
  125.                                         ChildAdded(Sub)
  126.                                 end
  127.                                 Part.ChildAdded:connect(ChildAdded)
  128.                                
  129.                                 local function Color()
  130.                                         for _,Sub in pairs(ColorParts) do
  131.                                                 Sub.BrickColor = Part.BrickColor
  132.                                                 local TexturePart = Sub:FindFirstChild("ShirtTexturePart")
  133.                                                 if TexturePart then
  134.                                                         TexturePart.BrickColor = Part.BrickColor
  135.                                                 end
  136.                                         end
  137.                                 end
  138.                                 Color()
  139.                                 Part.Changed:connect(Color)
  140.                         end
  141.                        
  142.                         Clear("HumanoidRootPart",HumanoidRootPart,{HumanoidRootPart})
  143.                         Clear("Head",Head,{Head})
  144.                         Clear("Torso",nil,{TorsoLower,TorsoUpper})
  145.                         Clear("Left Arm",nil,{LeftArmLower,LeftArmUpper,LeftHand})
  146.                         Clear("Right Arm",nil,{RightArmLower,RightArmUpper,RightHand})
  147.                         Clear("Left Leg",nil,{LeftLegLower,LeftLegUpper,LeftFoot})
  148.                         Clear("Right Leg",nil,{RightLegLower,RightLegUpper,RightFoot})
  149.                        
  150.                         local ShirtUsed = false
  151.                         local function ChildAdded(Ins)
  152.                                 if Ins:IsA("Hat") and string.sub(Ins.Name,1,7) ~= "Scaled_" then
  153.                                         delay(0.05,function()
  154.                                                 local Mesh = Ins:WaitForChild("Handle"):WaitForChild("Mesh")
  155.                                                 Ins.AttachmentPos = Ins.AttachmentPos
  156.                                                 Mesh.Scale = Mesh.Scale
  157.                                                 Ins.Name = "Scaled_"..Ins.Name
  158.                                         end)
  159.                                 elseif Ins:IsA("Shirt") then
  160.                                         ShirtUsed = true
  161.                                         TorsoLower.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  162.                                         TorsoUpper.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  163.                                         LeftArmLower.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  164.                                         LeftArmUpper.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  165.                                         LeftHand.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  166.                                         RightArmLower.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  167.                                         RightArmUpper.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  168.                                         RightHand.ShirtTexturePart.Mesh.TextureId = Ins.ShirtTemplate
  169.                                 elseif Ins:IsA("Pants") then
  170.                                         LeftLegUpper.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  171.                                         LeftLegLower.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  172.                                         LeftFoot.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  173.                                         RightLegUpper.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  174.                                         RightLegLower.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  175.                                         RightFoot.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  176.                                         if ShirtUsed ~= true then
  177.                                                 TorsoLower.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  178.                                                 TorsoUpper.ShirtTexturePart.Mesh.TextureId = Ins.PantsTemplate
  179.                                         end
  180.                                 end
  181.                         end
  182.                        
  183.                         for _,Sub in pairs(Character:GetChildren()) do
  184.                                 ChildAdded(Sub)
  185.                         end
  186.                         Character.ChildAdded:connect(ChildAdded)
  187.                 end
  188.         end
  189.        
  190.         CharacterAdded(Player.Character)
  191.         Player.CharacterAdded:connect(CharacterAdded)
  192.  
  193. script.Parent = Player.Character
  194. function   waitForChild(parent, childName)
  195.         local child = parent:findFirstChild(childName)
  196.         if child then return child end
  197.         while true do
  198.                 child = parent.ChildAdded:wait()
  199.                 if child.Name==childName then return child end
  200.         end
  201. end
  202.  
  203. local Figure = script.Parent
  204. local Humanoid = waitForChild(Figure, "Humanoid")
  205. local pose = "Standing"
  206.  
  207. local currentAnim = ""
  208. local currentAnimInstance = nil
  209. local currentAnimTrack = nil
  210. local currentAnimKeyframeHandler = nil
  211. local currentAnimSpeed = 1.0
  212. local animTable = {}
  213. local animNames = {
  214.         idle =         {        
  215.                                 { id = "http://www.roblox.com/asset/?id=361250879", weight = 1 },
  216.                                 { id = "http://www.roblox.com/asset/?id=361250964", weight = 1 },
  217.                                 { id = "http://www.roblox.com/asset/?id=361250801", weight = 9 }
  218.                         },
  219.         walk =         {        
  220.                                 { id = "http://www.roblox.com/asset/?id=361250532", weight = 10 }
  221.                         },
  222.         run =         {
  223.                                 { id = "http://www.roblox.com/asset/?id=361250532", weight = 10 }
  224.                         },
  225.         jump =         {
  226.                                 { id = "http://www.roblox.com/asset/?id=361251250", weight = 10 }
  227.                         },
  228.         fall =         {
  229.                                 { id = "http://www.roblox.com/asset/?id=361259102", weight = 10 }
  230.                         },
  231.         climb = {
  232.                                 { id = "http://www.roblox.com/asset/?id=361251073", weight = 10 }
  233.                         },
  234.         sit =         {
  235.                                 { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  236.                         },        
  237.         toolnone = {
  238.                                 { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  239.                         },
  240.         toolslash = {
  241.                                 { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  242. --                                { id = "slash.xml", weight = 10 }
  243.                         },
  244.         toollunge = {
  245.                                 { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  246.                         },
  247.         wave = {
  248.                                 { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  249.                         },
  250.         point = {
  251.                                 { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  252.                         },
  253.         dance = {
  254.                                 { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  255.                                 { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  256.                                 { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  257.                         },
  258.         dance2 = {
  259.                                 { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  260.                                 { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  261.                                 { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  262.                         },
  263.         dance3 = {
  264.                                 { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  265.                                 { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  266.                                 { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  267.                         },
  268.         laugh = {
  269.                                 { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  270.                         },
  271.         cheer = {
  272.                                 { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  273.                         },
  274.         tilt = {
  275.                                 { id = "http://www.roblox.com/asset/?id=3360692915", weight = 10 }
  276.                         },
  277.         stadium = {
  278.                                 { id = "http://www.roblox.com/asset/?id=3360686498", weight = 10 }
  279.                         },
  280.         salute = {
  281.                                 { id = "http://www.roblox.com/asset/?id=3360689775", weight = 10 }
  282.                         },
  283. }
  284.  
  285. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  286. local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false, tilt = true, stadium = true, salute = true}
  287.  
  288. math.randomseed(tick())
  289.  
  290. function configureAnimationSet(name, fileList)
  291.         if (animTable[name] ~= nil) then
  292.                 for _, connection in pairs(animTable[name].connections) do
  293.                         connection:disconnect()
  294.                 end
  295.         end
  296.         animTable[name] = {}
  297.         animTable[name].count = 0
  298.         animTable[name].totalWeight = 0        
  299.         animTable[name].connections = {}
  300.  
  301.         -- check for config values
  302.         local config = script:FindFirstChild(name)
  303.         if (config ~= nil) then
  304. --                print("Loading anims " .. name)
  305.                 table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  306.                 table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  307.                 local idx = 1
  308.                 for _, childPart in pairs(config:GetChildren()) do
  309.                         if (childPart:IsA("Animation")) then
  310.                                 table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  311.                                 animTable[name][idx] = {}
  312.                                 animTable[name][idx].anim = childPart
  313.                                 local weightObject = childPart:FindFirstChild("Weight")
  314.                                 if (weightObject == nil) then
  315.                                         animTable[name][idx].weight = 1
  316.                                 else
  317.                                         animTable[name][idx].weight = weightObject.Value
  318.                                 end
  319.                                 animTable[name].count = animTable[name].count + 1
  320.                                 animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  321.         --                        print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  322.                                 idx = idx + 1
  323.                         end
  324.                 end
  325.         end
  326.  
  327.         -- fallback to defaults
  328.         if (animTable[name].count <= 0) then
  329.                 for idx, anim in pairs(fileList) do
  330.                         animTable[name][idx] = {}
  331.                         animTable[name][idx].anim = Instance.new("Animation")
  332.                         animTable[name][idx].anim.Name = name
  333.                         animTable[name][idx].anim.AnimationId = anim.id
  334.                         animTable[name][idx].weight = anim.weight
  335.                         animTable[name].count = animTable[name].count + 1
  336.                         animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  337. --                        print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  338.                 end
  339.         end
  340. end
  341.  
  342. -- Setup animation objects
  343. function scriptChildModified(child)
  344.         local fileList = animNames[child.Name]
  345.         if (fileList ~= nil) then
  346.                 configureAnimationSet(child.Name, fileList)
  347.         end        
  348. end
  349.  
  350. script.ChildAdded:connect(scriptChildModified)
  351. script.ChildRemoved:connect(scriptChildModified)
  352.  
  353.  
  354. for name, fileList in pairs(animNames) do
  355.         configureAnimationSet(name, fileList)
  356. end        
  357.  
  358. -- ANIMATION
  359.  
  360. -- declarations
  361. local toolAnim = "None"
  362. local toolAnimTime = 0
  363.  
  364. local jumpAnimTime = 0
  365. local jumpAnimDuration = 0.3
  366.  
  367. local toolTransitionTime = 0.1
  368. local fallTransitionTime = 0.0
  369.  
  370. -- functions
  371.  
  372. function stopAllAnimations()
  373.         local oldAnim = currentAnim
  374.  
  375.         -- return to idle if finishing an emote
  376.         if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  377.                 oldAnim = "idle"
  378.         end
  379.  
  380.         currentAnim = ""
  381.         currentAnimInstance = nil
  382.         if (currentAnimKeyframeHandler ~= nil) then
  383.                 currentAnimKeyframeHandler:disconnect()
  384.         end
  385.  
  386.         if (currentAnimTrack ~= nil) then
  387.                 currentAnimTrack:Stop()
  388.                 currentAnimTrack:Destroy()
  389.                 currentAnimTrack = nil
  390.         end
  391.         return oldAnim
  392. end
  393.  
  394. function setAnimationSpeed(speed)
  395.         if speed ~= currentAnimSpeed then
  396.                 currentAnimSpeed = speed
  397.                 currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  398.         end
  399. end
  400.  
  401. function keyFrameReachedFunc(frameName)
  402.         if (frameName == "End") then
  403. --                print("Keyframe : ".. frameName)
  404.  
  405.                 local repeatAnim = currentAnim
  406.                 -- return to idle if finishing an emote
  407.                 if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  408.                         repeatAnim = "idle"
  409.                 end
  410.                
  411.                 local animSpeed = currentAnimSpeed
  412.                 playAnimation(repeatAnim, 0.05, Humanoid)
  413.                 setAnimationSpeed(animSpeed)
  414.         end
  415. end
  416.  
  417. -- Preload animations
  418. function playAnimation(animName, transitionTime, humanoid)
  419.                
  420.         local roll = math.random(1, animTable[animName].totalWeight)
  421.         local origRoll = roll
  422.         local idx = 1
  423.         while (roll > animTable[animName][idx].weight) do
  424.                 roll = roll - animTable[animName][idx].weight
  425.                 idx = idx + 1
  426.         end
  427.        
  428. --        print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  429.        
  430.         local anim = animTable[animName][idx].anim
  431.  
  432.         -- switch animation                
  433.         if (anim ~= currentAnimInstance) then
  434.                
  435.                 if (currentAnimTrack ~= nil) then
  436.                         currentAnimTrack:Stop(transitionTime)
  437.                         currentAnimTrack:Destroy()
  438.                 end
  439.  
  440.                 currentAnimSpeed = 1.0
  441.        
  442.                 -- load it to the humanoid; get AnimationTrack
  443.                 currentAnimTrack = humanoid:LoadAnimation(anim)
  444.                  
  445.                 -- play the animation
  446.                 currentAnimTrack:Play(transitionTime)
  447.                 currentAnim = animName
  448.                 currentAnimInstance = anim
  449.  
  450.                 -- set up keyframe name triggers
  451.                 if (currentAnimKeyframeHandler ~= nil) then
  452.                         currentAnimKeyframeHandler:disconnect()
  453.                 end
  454.                 currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  455.                
  456.         end
  457.  
  458. end
  459.  
  460. -------------------------------------------------------------------------------------------
  461. -------------------------------------------------------------------------------------------
  462.  
  463. local toolAnimName = ""
  464. local toolAnimTrack = nil
  465. local toolAnimInstance = nil
  466. local currentToolAnimKeyframeHandler = nil
  467.  
  468. function toolKeyFrameReachedFunc(frameName)
  469.         if (frameName == "End") then
  470. --                print("Keyframe : ".. frameName)        
  471.                 playToolAnimation(toolAnimName, 0.0, Humanoid)
  472.         end
  473. end
  474.  
  475.  
  476. function playToolAnimation(animName, transitionTime, humanoid)        
  477.                
  478.                 local roll = math.random(1, animTable[animName].totalWeight)
  479.                 local origRoll = roll
  480.                 local idx = 1
  481.                 while (roll > animTable[animName][idx].weight) do
  482.                         roll = roll - animTable[animName][idx].weight
  483.                         idx = idx + 1
  484.                 end
  485. --                print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  486.                 local anim = animTable[animName][idx].anim
  487.  
  488.                 if (toolAnimInstance ~= anim) then
  489.                        
  490.                         if (toolAnimTrack ~= nil) then
  491.                                 toolAnimTrack:Stop()
  492.                                 toolAnimTrack:Destroy()
  493.                                 transitionTime = 0
  494.                         end
  495.                                        
  496.                         -- load it to the humanoid; get AnimationTrack
  497.                         toolAnimTrack = humanoid:LoadAnimation(anim)
  498.                          
  499.                         -- play the animation
  500.                         toolAnimTrack:Play(transitionTime)
  501.                         toolAnimName = animName
  502.                         toolAnimInstance = anim
  503.  
  504.                         currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  505.                 end
  506. end
  507.  
  508. function stopToolAnimations()
  509.         local oldAnim = toolAnimName
  510.  
  511.         if (currentToolAnimKeyframeHandler ~= nil) then
  512.                 currentToolAnimKeyframeHandler:disconnect()
  513.         end
  514.  
  515.         toolAnimName = ""
  516.         toolAnimInstance = nil
  517.         if (toolAnimTrack ~= nil) then
  518.                 toolAnimTrack:Stop()
  519.                 toolAnimTrack:Destroy()
  520.                 toolAnimTrack = nil
  521.         end
  522.  
  523.  
  524.         return oldAnim
  525. end
  526.  
  527. -------------------------------------------------------------------------------------------
  528. -------------------------------------------------------------------------------------------
  529.  
  530.  
  531. function onRunning(speed)
  532.         if speed > 0.01 then
  533.                 playAnimation("walk", 0.1, Humanoid)
  534.                 if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=361250532" then
  535.                         setAnimationSpeed(speed / 14.5)
  536.                 end
  537.                 pose = "Running"
  538.         else
  539.                 playAnimation("idle", 0.1, Humanoid)
  540.                 pose = "Standing"
  541.         end
  542. end
  543.  
  544. function onDied()
  545.         pose = "Dead"
  546. end
  547.  
  548. function onJumping()
  549.         playAnimation("jump", 0.1, Humanoid)
  550.         jumpAnimTime = jumpAnimDuration
  551.         pose = "Jumping"
  552. end
  553.  
  554. function onClimbing(speed)
  555.         local scale = 2.0
  556.         playAnimation("climb", 0.1, Humanoid)
  557.         setAnimationSpeed(speed / scale)
  558.         pose = "Climbing"
  559. end
  560.  
  561. function onGettingUp()
  562.         pose = "GettingUp"
  563. end
  564.  
  565. function onFreeFall()
  566.         if (jumpAnimTime <= 0) then
  567.                 playAnimation("fall", fallTransitionTime, Humanoid)
  568.         end
  569.         pose = "FreeFall"
  570. end
  571.  
  572. function onFallingDown()
  573.         pose = "FallingDown"
  574. end
  575.  
  576. function onSeated()
  577.         pose = "Seated"
  578. end
  579.  
  580. function onPlatformStanding()
  581.         pose = "PlatformStanding"
  582. end
  583.  
  584. function onSwimming(speed)
  585.         if speed>0 then
  586.                 pose = "Running"
  587.         else
  588.                 pose = "Standing"
  589.         end
  590. end
  591.  
  592. function getTool()        
  593.         for _, kid in ipairs(Figure:GetChildren()) do
  594.                 if kid.className == "Tool" then return kid end
  595.         end
  596.         return nil
  597. end
  598.  
  599. function getToolAnim(tool)
  600.         for _, c in ipairs(tool:GetChildren()) do
  601.                 if c.Name == "toolanim" and c.className == "StringValue" then
  602.                         return c
  603.                 end
  604.         end
  605.         return nil
  606. end
  607.  
  608. function animateTool()
  609.        
  610.         if (toolAnim == "None") then
  611.                 playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  612.                 return
  613.         end
  614.  
  615.         if (toolAnim == "Slash") then
  616.                 playToolAnimation("toolslash", 0, Humanoid)
  617.                 return
  618.         end
  619.  
  620.         if (toolAnim == "Lunge") then
  621.                 playToolAnimation("toollunge", 0, Humanoid)
  622.                 return
  623.         end
  624. end
  625.  
  626. function moveSit()
  627.         RightShoulder.MaxVelocity = 0.15
  628.         LeftShoulder.MaxVelocity = 0.15
  629.         RightShoulder:SetDesiredAngle(3.14 /2)
  630.         LeftShoulder:SetDesiredAngle(-3.14 /2)
  631.         RightHip:SetDesiredAngle(3.14 /2)
  632.         LeftHip:SetDesiredAngle(-3.14 /2)
  633. end
  634.  
  635. local lastTick = 0
  636.  
  637. function move(time)
  638.         local amplitude = 1
  639.         local frequency = 1
  640.           local deltaTime = time - lastTick
  641.           lastTick = time
  642.  
  643.         local climbFudge = 0
  644.         local setAngles = false
  645.  
  646.           if (jumpAnimTime > 0) then
  647.                   jumpAnimTime = jumpAnimTime - deltaTime
  648.           end
  649.  
  650.         if (pose == "FreeFall" and jumpAnimTime <= 0) then
  651.                 playAnimation("fall", fallTransitionTime, Humanoid)
  652.         elseif (pose == "Seated") then
  653.                 playAnimation("sit", 0.5, Humanoid)
  654.                 return
  655.         elseif (pose == "Running") then
  656.                 playAnimation("walk", 0.1, Humanoid)
  657.         elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  658. --                print("Wha " .. pose)
  659.                 stopAllAnimations()
  660.                 amplitude = 0.1
  661.                 frequency = 1
  662.                 setAngles = true
  663.         end
  664.  
  665. --        if (setAngles) then
  666.         if (false) then
  667.                 desiredAngle = amplitude * math.sin(time * frequency)
  668.  
  669.                 RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  670.                 LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  671.                 RightHip:SetDesiredAngle(-desiredAngle)
  672.                 LeftHip:SetDesiredAngle(-desiredAngle)
  673.         end
  674.  
  675.         -- Tool Animation handling
  676.         local tool = getTool()
  677.         if tool then
  678.        
  679.                 animStringValueObject = getToolAnim(tool)
  680.  
  681.                 if animStringValueObject then
  682.                         toolAnim = animStringValueObject.Value
  683.                         -- message recieved, delete StringValue
  684.                         animStringValueObject.Parent = nil
  685.                         toolAnimTime = time + .3
  686.                 end
  687.  
  688.                 if time > toolAnimTime then
  689.                         toolAnimTime = 0
  690.                         toolAnim = "None"
  691.                 end
  692.  
  693.                 animateTool()                
  694.         else
  695.                 stopToolAnimations()
  696.                 toolAnim = "None"
  697.                 toolAnimInstance = nil
  698.                 toolAnimTime = 0
  699.         end
  700. end
  701.  
  702. -- connect events
  703. Humanoid.Died:connect(onDied)
  704. Humanoid.Running:connect(onRunning)
  705. Humanoid.Jumping:connect(onJumping)
  706. Humanoid.Climbing:connect(onClimbing)
  707. Humanoid.GettingUp:connect(onGettingUp)
  708. Humanoid.FreeFalling:connect(onFreeFall)
  709. Humanoid.FallingDown:connect(onFallingDown)
  710. Humanoid.Seated:connect(onSeated)
  711. Humanoid.PlatformStanding:connect(onPlatformStanding)
  712. Humanoid.Swimming:connect(onSwimming)
  713.  
  714. -- setup emote chat hook
  715. Player.Chatted:connect(function(msg)
  716.         local emote = ""
  717.         if (string.sub(msg, 1, 3) == "/e ") then
  718.                 emote = string.sub(msg, 4)
  719.         elseif (string.sub(msg, 1, 7) == "/emote ") then
  720.                 emote = string.sub(msg, 8)
  721.         end
  722.        
  723.         if (pose == "Standing" and emoteNames[emote] ~= nil) then
  724.                 playAnimation(emote, 0.1, Humanoid)
  725.         end
  726. --        print("===> " .. string.sub(msg, 1, 3) .. "(" .. emote .. ")")
  727. end)
  728.  
  729.  
  730. -- main program
  731.  
  732. local runService = game:service("RunService");
  733.  
  734. -- print("bottom")
  735.  
  736. -- initialize to idle
  737. playAnimation("idle", 0.1, Humanoid)
  738. pose = "Standing"
  739.  
  740. while Figure.Parent~=nil do
  741.         local _, time = wait(0.1)
  742.         move(time)
  743. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement