Prephy

Void SB Dummy

May 12th, 2021 (edited)
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.72 KB | None | 0 0
  1. wait()
  2. player = owner
  3. oldpos = nil
  4. name=nil
  5. local partmat = {"Part","FlagStand","Part"}
  6. local Motor = 'Motor'
  7.  
  8.  
  9.  
  10.  
  11. function char()
  12.  
  13.     name = 'Dummy'
  14.     local mod = Instance.new("Model",workspace) mod.Name = name
  15.     local torso = Instance.new(partmat[math.random(1,#partmat)],mod) torso.CFrame = oldpos.CFrame torso.Name="Torso" torso.Size = Vector3.new(2,2,1)torso.Reflectance = 0 torso.CanCollide=true torso.Transparency=0 torso.BrickColor=BrickColor.new("New Yeller")
  16.     local head = Instance.new(partmat[math.random(1,#partmat)],mod) head.Name="Head" head.Size = Vector3.new(2,1,1)    local dec = Instance.new("Decal",head) dec.Texture="http://www.roblox.com/asset/?id=231473182" dec.Name=math.random() head.CanCollide=false  head.Reflectance=0 head.Transparency=0 head.BrickColor=BrickColor.new("Br. yellowish green")
  17.     local mesh = Instance.new("SpecialMesh",head) mesh.MeshId="rbxassetid://1104623876" mesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  18.     local r_leg = Instance.new(partmat[math.random(1,#partmat)],mod) r_leg.Name="Right Leg" r_leg.Size = Vector3.new(1,2,1)  r_leg.Reflectance = 0 r_leg.CanCollide=false r_leg.Transparency=0 r_leg.BrickColor=BrickColor.new("New Yeller")
  19.     local l_leg = Instance.new(partmat[math.random(1,#partmat)],mod) l_leg.Name="Left Leg" l_leg.Size = Vector3.new(1,2,1)   l_leg.Reflectance = 0 l_leg.CanCollide=false l_leg.Transparency=0 l_leg.BrickColor=BrickColor.new("New Yeller")
  20.     local l_arm = Instance.new(partmat[math.random(1,#partmat)],mod) l_arm.Name="Left Arm" l_arm.Size = Vector3.new(1,2,1)   l_arm.Reflectance = 0 l_arm.CanCollide=false l_arm.Transparency=0 l_arm.BrickColor=BrickColor.new("Br. yellowish green")
  21.     local r_arm = Instance.new(partmat[math.random(1,#partmat)],mod) r_arm.Name="Right Arm" r_arm.Size = Vector3.new(1,2,1)  r_arm.Reflectance = 0 r_arm.CanCollide=false r_arm.Transparency=0 r_arm.BrickColor=BrickColor.new("Br. yellowish green")
  22.  
  23.  
  24.     function waitForChild(parent, childName)
  25.         local child = parent:findFirstChild(childName)
  26.         if child then return child end
  27.         while true do
  28.             child = parent.ChildAdded:wait()
  29.             if child.Name==childName then return child end
  30.         end
  31.     end
  32.  
  33.  
  34.     local Figure = mod
  35.     local Torso = waitForChild(Figure, "Torso")
  36.  
  37.     function makeJoint(limbName, jointName, c0, c1)
  38.         local limb = waitForChild(Figure, limbName)
  39.         limb:BreakJoints()
  40.         local joint = Instance.new(Motor)
  41.         joint.Name = jointName
  42.         joint.Part0 = Torso
  43.         joint.Part1 = limb
  44.         joint.C0 = c0
  45.         joint.C1 = c1
  46.         joint.MaxVelocity = 0.15
  47.         joint.archivable = false
  48.         joint.Parent = Torso
  49.         return joint
  50.     end
  51.  
  52.     local Neck = makeJoint("Head","Neck", CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0), CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0))
  53.     local RightShoulder = makeJoint("Right Arm", "Right Shoulder", CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0))
  54.     local LeftShoulder = makeJoint("Left Arm", "Left Shoulder", CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0))
  55.     local RightHip = makeJoint("Right Leg", "Right Hip", CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0))
  56.     local LeftHip = makeJoint("Left Leg", "Left Hip", CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0))
  57.  
  58.  
  59.  
  60.  
  61.     oldpos = torso
  62.     player.Character = mod
  63.     wait()
  64.    
  65.    
  66.     local Torso = torso --waitForChild(Figure, "Torso")
  67.     local Humanoid =  Instance.new("Humanoid",Figure) Humanoid.BreakJointsOnDeath=false Humanoid.RequiresNeck=false Humanoid.MaxHealth=100 Humanoid.Health=100 --waitForChild(Figure, "Humanoid")
  68.     workspace.CurrentCamera.CameraSubject=Humanoid
  69.    
  70.     -- functions
  71.  
  72.  
  73.  
  74.     local toolAnim = "None"
  75.     local toolAnimTime = 0
  76.  
  77.     -- functions
  78.  
  79.     function onRunning(speed)
  80.         if speed>0 then
  81.             pose = "Running"
  82.         else
  83.             pose = "Standing"
  84.         end
  85.     end
  86.  
  87.     function onDied()
  88.         char()
  89.         pose = "Dead"
  90.     end
  91.  
  92.     function onJumping(state)
  93.         pose = "Jumping"
  94.     end
  95.  
  96.     function onClimbing()
  97.         pose = "Climbing"
  98.     end
  99.  
  100.     function onGettingUp(state)
  101.         pose = "GettingUp"
  102.     end
  103.  
  104.     function onFreeFall(state)
  105.         pose = "FreeFall"
  106.     end
  107.  
  108.     function onFallingDown(state)
  109.         pose = "FallingDown"
  110.     end
  111.  
  112.     function onSeated()
  113.         pose = "Seated"
  114.     end
  115.  
  116.     function moveJump()
  117.         RightShoulder.MaxVelocity = 0.5
  118.         LeftShoulder.MaxVelocity = 0.5
  119.         RightShoulder.DesiredAngle = 3.14
  120.         LeftShoulder.DesiredAngle = -3.14
  121.         RightHip.DesiredAngle = 0
  122.         LeftHip.DesiredAngle = 0
  123.     end
  124.  
  125.  
  126.     -- same as jump for now
  127.  
  128.     function moveFreeFall()
  129.         RightShoulder.MaxVelocity = 0.5
  130.         LeftShoulder.MaxVelocity = 0.5
  131.         RightShoulder.DesiredAngle = 3.14
  132.         LeftShoulder.DesiredAngle = -3.14
  133.         RightHip.DesiredAngle = 0
  134.         LeftHip.DesiredAngle = 0
  135.     end
  136.  
  137.     function moveSit()
  138.         RightShoulder.MaxVelocity = 0.15
  139.         LeftShoulder.MaxVelocity = 0.15
  140.         RightShoulder.DesiredAngle = 3.14 /2
  141.         LeftShoulder.DesiredAngle = -3.14 /2
  142.         RightHip.DesiredAngle = 3.14 /2
  143.         LeftHip.DesiredAngle = -3.14 /2
  144.     end
  145.  
  146.     local function getTool()
  147.         for i, v in ipairs(Figure:GetChildren()) do
  148.             if v:IsA"Tool" then
  149.                 return v
  150.             end
  151.         end
  152.         return nil
  153.     end
  154.  
  155.     function getToolAnim(tool)
  156.         for _, c in ipairs(tool:GetChildren()) do
  157.             if c.Name == "toolanim" and c.className == "StringValue" then
  158.                 return c
  159.             end
  160.         end
  161.         return nil
  162.     end
  163.  
  164.     function animateTool()
  165.  
  166.         if (toolAnim == "None") then
  167.             RightShoulder.DesiredAngle = 1.57
  168.             return
  169.         end
  170.  
  171.         if (toolAnim == "Slash") then
  172.             RightShoulder.MaxVelocity = 0.5
  173.             RightShoulder.DesiredAngle = 0
  174.             return
  175.         end
  176.  
  177.         if (toolAnim == "Lunge") then
  178.             RightShoulder.MaxVelocity = 0.5
  179.             LeftShoulder.MaxVelocity = 0.5
  180.             RightHip.MaxVelocity = 0.5
  181.             LeftHip.MaxVelocity = 0.5
  182.             RightShoulder.DesiredAngle = 1.57
  183.             LeftShoulder.DesiredAngle = 1.0
  184.             RightHip.DesiredAngle = 1.57
  185.             LeftHip.DesiredAngle = 1.0
  186.             return
  187.         end
  188.     end
  189.  
  190.     function move(time)
  191.         local amplitude
  192.         local frequency
  193.  
  194.         if (pose == "Jumping") then
  195.             moveJump()
  196.             return
  197.         end
  198.  
  199.         if (pose == "FreeFall") then
  200.             moveFreeFall()
  201.             return
  202.         end
  203.  
  204.         if (pose == "Seated") then
  205.             moveSit()
  206.             return
  207.         end
  208.  
  209.         local climbFudge = 0
  210.  
  211.         if (pose == "Running") then
  212.             RightShoulder.MaxVelocity = 0.15
  213.             LeftShoulder.MaxVelocity = 0.15
  214.             amplitude = 1
  215.             frequency = 9
  216.         elseif (pose == "Climbing") then
  217.             RightShoulder.MaxVelocity = 0.5
  218.             LeftShoulder.MaxVelocity = 0.5
  219.             amplitude = 1
  220.             frequency = 9
  221.             climbFudge = 3.14
  222.         else
  223.             amplitude = 0.1
  224.             frequency = 1
  225.         end
  226.  
  227.         desiredAngle = amplitude * math.sin(time*frequency)
  228.  
  229.         RightShoulder.DesiredAngle = desiredAngle + climbFudge
  230.         LeftShoulder.DesiredAngle = desiredAngle - climbFudge
  231.         RightHip.DesiredAngle = -desiredAngle
  232.         LeftHip.DesiredAngle = -desiredAngle
  233.  
  234.  
  235.         local tool = getTool()
  236.  
  237.         if tool then
  238.  
  239.             animStringValueObject = getToolAnim(tool)
  240.  
  241.             if animStringValueObject then
  242.                 toolAnim = animStringValueObject.Value
  243.                 -- message recieved, delete StringValue
  244.                 animStringValueObject.Parent = nil
  245.                 toolAnimTime = time + .3
  246.             end
  247.  
  248.             if time > toolAnimTime then
  249.                 toolAnimTime = 0
  250.                 toolAnim = "None"
  251.             end
  252.  
  253.             animateTool()
  254.  
  255.  
  256.         else
  257.             toolAnim = "None"
  258.             toolAnimTime = 0
  259.         end
  260.     end
  261.  
  262.  
  263.     -- connect events
  264.  
  265.     Humanoid.Died:connect(onDied)
  266.     Humanoid.Running:connect(onRunning)
  267.     Humanoid.Jumping:connect(onJumping)
  268.     Humanoid.Climbing:connect(onClimbing)
  269.     Humanoid.GettingUp:connect(onGettingUp)
  270.     Humanoid.FreeFalling:connect(onFreeFall)
  271.     Humanoid.FallingDown:connect(onFallingDown)
  272.     Humanoid.Seated:connect(onSeated)
  273.  
  274.  
  275.  
  276.     -- main program
  277.  
  278.     local runService = game:service("RunService");
  279.     while Figure.Parent~=nil do
  280.         local _, time = wait(0.1)
  281.         move(time)
  282.     end
  283.    
  284.    
  285. end
  286.  
  287.  
  288. if player.Character then
  289.  
  290.     local h = player.Character:FindFirstChild("HumanoidRootPart")
  291.     if h then
  292.         oldpos = h
  293.         char()
  294.     else
  295.         local hez = player.Character:FindFirstChild("Head")
  296.         if hez then
  297.             oldpos = hez
  298.             char()
  299.         else
  300.             char()
  301.         end
  302.     end
  303. else
  304.     char()
  305. end
  306.  
  307.  
  308.  
  309. local run = game:GetService("RunService")
  310. local sec = 5
  311. run.Heartbeat:Connect(function(WHAT)
  312.     local nice = sec * WHAT
  313.     local oo =  workspace:FindFirstChild(name)
  314.     if oo then
  315.         local h = oo:FindFirstChild("Head")
  316.         if h then
  317.         else
  318.             char()
  319.         end
  320.         local Rl = oo:FindFirstChild("Right Leg")
  321.         if Rl then
  322.         else
  323.             char()
  324.         end
  325.         local Ll = oo:FindFirstChild("Left Leg")
  326.         if Ll then
  327.         else
  328.             char()
  329.         end
  330.         local Larm = oo:FindFirstChild("Left Arm")
  331.         if Larm then
  332.         else
  333.             char()
  334.         end
  335.        
  336.  
  337.         local Rarm = oo:FindFirstChild("Right Arm")
  338.         if Rarm then
  339.         else
  340.             char()
  341.         end
  342.        
  343.        
  344.         local T = oo:FindFirstChild("Torso")
  345.         if T then
  346.         else
  347.             char()
  348.         end
  349.     else
  350.         char()
  351.     end
  352. end)
Add Comment
Please, Sign In to add comment