Advertisement
SubScripts

Worm

Jun 23rd, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.88 KB | None | 0 0
  1. IT = Instance.new
  2. CF = CFrame.new
  3. VT = Vector3.new
  4. RAD = math.rad
  5. C3 = Color3.new
  6. UD2 = UDim2.new
  7. BRICKC = BrickColor.new
  8. ANGLES = CFrame.Angles
  9. EULER = CFrame.fromEulerAnglesXYZ
  10. COS = math.cos
  11. ACOS = math.acos
  12. SIN = math.sin
  13. ASIN = math.asin
  14. ABS = math.abs
  15. MRANDOM = math.random
  16. FLOOR = math.floor
  17. Eating = true
  18. Eaten = 0
  19. AllowSit = false
  20. Networth = 0
  21. Frame_Speed = 1 / 60 -- (1 / 30) OR (1 / 60)
  22.  
  23.  
  24.  
  25. ArtificialHB = Instance.new("BindableEvent", script)
  26. ArtificialHB.Name = "ArtificialHB"
  27.  
  28. script:WaitForChild("ArtificialHB")
  29.  
  30. frame = Frame_Speed
  31. tf = 0
  32. allowframeloss = false
  33. tossremainder = false
  34. lastframe = tick()
  35. script.ArtificialHB:Fire()
  36.  
  37. game:GetService("RunService").Heartbeat:connect(function(s, p)
  38.     tf = tf + s
  39.     if tf >= frame then
  40.         if allowframeloss then
  41.             script.ArtificialHB:Fire()
  42.             lastframe = tick()
  43.         else
  44.             for i = 1, math.floor(tf / frame) do
  45.                 script.ArtificialHB:Fire()
  46.             end
  47.         lastframe = tick()
  48.         end
  49.         if tossremainder then
  50.             tf = 0
  51.         else
  52.             tf = tf - frame * math.floor(tf / frame)
  53.         end
  54.     end
  55. end)
  56.  
  57.  
  58. function Swait(NUMBER)
  59.     if NUMBER == 0 or NUMBER == nil then
  60.         ArtificialHB.Event:wait()
  61.     else
  62.         for i = 1, NUMBER do
  63.             ArtificialHB.Event:wait()
  64.         end
  65.     end
  66. end
  67.  
  68. function CreateSeat(FORMFACTOR, PARENT, MATERIAL, REFLECTANCE, TRANSPARENCY, BRICKCOLOR, NAME, SIZE, ANCHOR)
  69.     local NEWPART = IT("Seat")
  70.     NEWPART.formFactor = FORMFACTOR
  71.     NEWPART.Reflectance = REFLECTANCE
  72.     NEWPART.Transparency = TRANSPARENCY
  73.     NEWPART.CanCollide = false
  74.     NEWPART.Locked = true
  75.     NEWPART.Anchored = true
  76.     if ANCHOR == false then
  77.         NEWPART.Anchored = false
  78.     end
  79.     NEWPART.BrickColor = BRICKC(tostring(BRICKCOLOR))
  80.     NEWPART.Name = NAME
  81.     NEWPART.Size = SIZE
  82.     NEWPART.Position = Torso.Position
  83.     NEWPART.Material = MATERIAL
  84.     NEWPART:BreakJoints()
  85.     NEWPART.Parent = PARENT
  86.     return NEWPART
  87. end
  88.  
  89. function CreateWeldOrSnapOrMotor(TYPE, PARENT, PART0, PART1, C0, C1)
  90.     local NEWWELD = IT(TYPE)
  91.     NEWWELD.Part0 = PART0
  92.     NEWWELD.Part1 = PART1
  93.     NEWWELD.C0 = C0
  94.     NEWWELD.C1 = C1
  95.     NEWWELD.Parent = PARENT
  96.     return NEWWELD
  97. end
  98.  
  99.  
  100. Player = owner
  101. PlayerGui = Player.PlayerGui
  102. Cam = workspace.CurrentCamera
  103. Backpack = Player.Backpack
  104. Character = Player.Character
  105. Humanoid = Character.Humanoid
  106. RootPart = Character["HumanoidRootPart"]
  107. Torso = Character["Torso"]
  108. Head = Character["Head"]
  109. RightArm = Character["Right Arm"]
  110. LeftArm = Character["Left Arm"]
  111. RightLeg = Character["Right Leg"]
  112. LeftLeg = Character["Left Leg"]
  113. RootJoint = RootPart["RootJoint"]
  114. Neck = Torso["Neck"]
  115. RightShoulder = Torso["Right Shoulder"]
  116. LeftShoulder = Torso["Left Shoulder"]
  117. RightHip = Torso["Right Hip"]
  118. LeftHip = Torso["Left Hip"]
  119.  
  120.  
  121. function CreatePart(FORMFACTOR, PARENT, MATERIAL, REFLECTANCE, TRANSPARENCY, BRICKCOLOR, NAME, SIZE, ANCHOR)
  122.     local NEWPART = IT("Part")
  123.     NEWPART.formFactor = FORMFACTOR
  124.     NEWPART.Reflectance = REFLECTANCE
  125.     NEWPART.Transparency = TRANSPARENCY
  126.     NEWPART.CanCollide = false
  127.     NEWPART.Locked = true
  128.     NEWPART.Anchored = true
  129.     if ANCHOR == false then
  130.         NEWPART.Anchored = false
  131.     end
  132.     NEWPART.BrickColor = BRICKC(tostring(BRICKCOLOR))
  133.     NEWPART.Name = NAME
  134.     NEWPART.Size = SIZE
  135.     NEWPART.Position = Torso.Position
  136.     NEWPART.Material = MATERIAL
  137.     NEWPART:BreakJoints()
  138.     NEWPART.Parent = PARENT
  139.     return NEWPART
  140. end
  141.  
  142. function ezweld(P1,P2,CFRAME)
  143.     local ezweld = CreateWeldOrSnapOrMotor("Weld",Character,P1,P2,CFRAME,CF(0,0,0))
  144. end
  145.  
  146. local WormHead = CreatePart(3,Character,"SmoothPlastic",0,0,103,"OofHead",VT(4,4,4),false)
  147. ezweld(WormHead,Torso,CF(0,0,0))
  148. local Setg = CreateSeat(3,Character,"SmoothPlastic",0,1,"White","OofHead",VT(2,0.1,2),false)
  149. ezweld(Setg,WormHead,CF(0,-2,0))
  150. if AllowSit ==  false then
  151.     Setg.Disabled = true
  152. end
  153. WormHead.CanCollide = true
  154. local Fac = Instance.new("Decal",WormHead)
  155. Fac.Face = "Front"
  156. local RandomFace = math.random(1,3)
  157. if RandomFace == 1 then
  158.     Fac.Texture = "rbxassetid://15298379"
  159. else if RandomFace == 2 then
  160.     Fac.Texture = "rbxassetid://162136529"
  161. else
  162.     Fac.Texture = "rbxassetid://282463320"
  163. end
  164. end
  165. LatestP = WormHead
  166.  
  167.  
  168. local EatPart = CreatePart(3,Character,"SmoothPlastic",0,1,"White","OofHead",VT(4,4,0),false)
  169. ezweld(EatPart,WormHead,CF(0,0,2))
  170.  
  171.  
  172. EatPart.Touched:Connect(function(nom)
  173.     if Eating == true and nom.Name ~= "Base" and nom.Parent ~= Character and nom.Parent.Parent ~= Character and nom:IsA("Part") then
  174.         nom:Remove()
  175.         Humanoid.WalkSpeed = Humanoid.WalkSpeed + 0.1
  176.         Eaten = Eaten + 1
  177.         local bom = Character:FindFirstChild("Eating")
  178.         if bom then
  179.             bom:Play()
  180.         end
  181.         Networth = Networth +1
  182.         if Eaten == 3 or Eaten > 3 then
  183.             Eaten = 0
  184.             local AP = CreatePart(3,Character,"SmoothPlastic",0,0,"Industrial White","Sitting",VT(4,4,4),false)
  185.             ezweld(AP,LatestP,CF(0,-0.2,-3))
  186.             AP.Massless = true
  187.             Swait()
  188.             AP.CanCollide = true
  189.             Swait(2)
  190.             AP:BreakJoints()
  191.             local Rope = Instance.new("SpringConstraint",LatestP)
  192.             local Attach = Instance.new("Attachment",LatestP)
  193.             local Attach2 = Instance.new("Attachment",AP)
  194.             Attach.Position = VT(0,0,2)
  195.             Attach2.Position = VT(0,0,-2)
  196.             Rope.Attachment0 = Attach
  197.             Rope.Attachment1 = Attach2
  198.             Rope.Visible = false
  199.             Rope.Color = BRICKC("New Yeller")
  200.             Rope.Coils = 3
  201.             Rope.Radius = 0.1
  202.             Rope.MaxLength = 1
  203.             Rope.MinLength = 0
  204.             Rope.MaxForce = 0.2
  205.             Rope.LimitsEnabled = true
  206.             LatestP = AP
  207.         end
  208.     end
  209. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement