Advertisement
DrakrMakr

Darkus v2

Aug 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 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.  
  3. local Player,game,owner = owner,game
  4.  
  5. local RealPlayer = Player
  6.  
  7. do local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
  8. Player = game:GetService("Players").LocalPlayer
  9. Char = Player.Character
  10. local Sound = Instance.new("Sound", Char.Torso)
  11. Sound.SoundId = "http://www.roblox.com/asset/?id=1907454616"
  12. Sound.Volume = 1
  13. Sound.TimePosition = 12.919996252995535002
  14. Sound.Looped = true
  15. Sound:Play()
  16. function recurse(root,callback,i)
  17. coroutine.resume(coroutine.create(function()
  18. i= i or 0
  19. for _,v in pairs(root:GetChildren()) do
  20. i = i + 1
  21. callback(i,v)
  22.  
  23. if #v:GetChildren() > 0 then
  24. i = recurse(v,callback,i)
  25. end
  26. end
  27. end))
  28. return i
  29. end
  30. function MakeAth(AthParent,AthName,AthPosX,AthPosY,AthPosZ,AthRot,AthAX,SecondaryAxis)
  31.  
  32. coroutine.resume(coroutine.create(function()
  33. local ATH = Instance.new("Attachment",AthParent)
  34. ATH.Position = Vector3.new(AthPosX,AthPosY,AthPosZ)
  35. ATH.Name = AthName
  36. if AthRot ~= nil then
  37. ATH.Rotation = AthRot end
  38. if AthAX ~= nil then
  39. ATH.Axis = AthAX end
  40. if SecondaryAxis ~= nil then
  41. ATH.SecondaryAxis = SecondaryAxis end
  42. end))
  43. end
  44. function getAttachment0(attachmentName,Rcharacter)
  45. for i, child in pairs(GatherAllInstances(Rcharacter)) do
  46. local attachment = child:FindFirstChild(attachmentName)
  47. if attachment then
  48. return attachment
  49.  
  50. end
  51.  
  52. end
  53.  
  54.  
  55.  
  56.  
  57.  
  58. end
  59. function makrag(Rcharacter)
  60.  
  61.  
  62. --HitModel
  63.  
  64.  
  65. local camera = workspace.CurrentCamera
  66.  
  67. --Make it so ragdoll can't collide with invisible HRP, but don't let HRP fall through map and be destroyed in process
  68. coroutine.resume(coroutine.create(function()
  69. if Rcharacter:FindFirstChild("HumanoidRootPart")then
  70. Rcharacter.HumanoidRootPart.Anchored = true
  71. Rcharacter.HumanoidRootPart.CanCollide = false
  72. --- Rcharacter.HumanoidRootPart.Position = Vector3.new(0,-10,0)
  73. Rcharacter.HumanoidRootPart.Parent = nil
  74. end
  75. end))
  76. --Helps to fix constraint spasms
  77. recurse(Rcharacter, function(_,v)
  78. if v:IsA("Attachment") then
  79. v.Axis = Vector3.new(0, 1, 0)
  80. v.SecondaryAxis = Vector3.new(0, 0, 1)
  81. v.Rotation = Vector3.new(0, 0, 0)
  82. end
  83. end)
  84.  
  85. --Re-attach hats
  86.  
  87.  
  88. coroutine.resume(coroutine.create(function()
  89. if Rcharacter:FindFirstChild("Torso")then
  90.  
  91. local RMT = Rcharacter:FindFirstChild("Torso")
  92.  
  93. local RMH = Rcharacter:FindFirstChild("Head")
  94.  
  95. local RLA = Rcharacter:FindFirstChild("Left Arm")
  96.  
  97. local RRA = Rcharacter:FindFirstChild("Right Arm")
  98.  
  99. local RLL = Rcharacter:FindFirstChild("Left Leg")
  100.  
  101. local RRL = Rcharacter:FindFirstChild("Right Leg")
  102.  
  103. --MakeAth(RMH,"",0,0,0)
  104. MakeAth(RMH,"NeckRigAttachment",0,-.5,0)
  105. MakeAth(RRA,"RightShoulderRigAttachment",-0.4, 0.8, 0,Vector3.new(-180, 0, 90),Vector3.new(0, -1, -0),Vector3.new(0, 1, 0))
  106. MakeAth(RLA,"LeftShoulderRigAttachment",0.4, 0.8, 0,Vector3.new(-180, 0, 90),Vector3.new(0, -1, -0),Vector3.new(-1, 0, 0))
  107. MakeAth(RRL,"RightHipRigAttachment",0, 1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
  108. MakeAth(RLL,"LeftHipRigAttachment",0, 1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
  109. ------------------------------------------------------
  110. MakeAth(RMT,"NeckRigAttachment",0, 1, 0)
  111. MakeAth(RMT,"RightShoulderRigAttachment",1, 0.8, 0,Vector3.new(-180, 0, 0),Vector3.new(1, -0, 0),Vector3.new(0, -1, 0))
  112. MakeAth(RMT,"LeftShoulderRigAttachment",-1, 0.8, 0,Vector3.new(0, 0, -180),Vector3.new(-1, -0, 0),Vector3.new(0, -1, 0))
  113. MakeAth(RMT,"RightHipRigAttachment",0.5, -1.1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
  114. MakeAth(RMT,"LeftHipRigAttachment",-0.5, -1.1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. coroutine.resume(coroutine.create(function()
  124. local LAT = Instance.new("BallSocketConstraint")
  125. LAT.Parent = RMT
  126. LAT.Attachment0 = RLA.LeftShoulderRigAttachment
  127. LAT.Attachment1 = RMT.LeftShoulderRigAttachment
  128. LAT.Enabled = true
  129. LAT.LimitsEnabled=true
  130. LAT.UpperAngle=70
  131. end))
  132. coroutine.resume(coroutine.create(function()
  133. local RAT = Instance.new("BallSocketConstraint")
  134. RAT.Parent = RMT
  135. RAT.Attachment0 = RRA.RightShoulderRigAttachment
  136. RAT.Attachment1 = RMT.RightShoulderRigAttachment
  137. RAT.Enabled = true
  138. RAT.LimitsEnabled=true
  139. RAT.UpperAngle=70
  140. end))
  141. coroutine.resume(coroutine.create(function()
  142. local TLL = Instance.new("BallSocketConstraint")
  143. TLL.Parent = RMT
  144. TLL.Attachment0 = RLL.LeftHipRigAttachment
  145. TLL.Attachment1 = RMT.LeftHipRigAttachment
  146. TLL.Enabled = true
  147. TLL.LimitsEnabled=true
  148. TLL.UpperAngle=70
  149. end))
  150. coroutine.resume(coroutine.create(function()
  151. local TRL = Instance.new("BallSocketConstraint")
  152. TRL.Parent = RMT
  153. TRL.Attachment0 = RRL.RightHipRigAttachment
  154. TRL.Attachment1 = RMT.RightHipRigAttachment
  155. TRL.Enabled = true
  156. TRL.LimitsEnabled=true
  157. TRL.UpperAngle=70
  158. end))
  159.  
  160. end
  161. end))
  162. coroutine.resume(coroutine.create(function()
  163. ragdollJoint(Rcharacter.LowerTorso, Rcharacter.UpperTorso, "WaistRigAttachment", "BallSocket", {
  164. {"LimitsEnabled",true};
  165. {"UpperAngle",5};
  166. }) end)) coroutine.resume(coroutine.create(function()
  167. local NeckProperties = {
  168. {"LimitsEnabled", true};
  169. {"UpperAngle",5};
  170.  
  171. }
  172. local Rtorso = Rcharacter:FindFirstChild("Torso") or Rcharacter:FindFirstChild("UpperTorso")
  173. ragdollJoint(Rtorso, Rcharacter.Head, "NeckRigAttachment", "Hinge", NeckProperties)
  174. end)) coroutine.resume(coroutine.create(function()
  175.  
  176. local handProperties = {
  177. {"LimitsEnabled", true};
  178. {"UpperAngle",0};
  179. {"LowerAngle",0};
  180. }
  181. ragdollJoint(Rcharacter.LeftLowerArm, Rcharacter.LeftHand, "LeftWristRigAttachment", "Hinge", handProperties)
  182. ragdollJoint(Rcharacter.RightLowerArm, Rcharacter.RightHand, "RightWristRigAttachment", "Hinge", handProperties)
  183. end)) coroutine.resume(coroutine.create(function()
  184. local shinProperties = {
  185. {"LimitsEnabled", true};
  186. {"UpperAngle", 0};
  187. {"LowerAngle", -75};
  188. }
  189. ragdollJoint(Rcharacter.LeftUpperLeg, Rcharacter.LeftLowerLeg, "LeftKneeRigAttachment", "Hinge", shinProperties)
  190. ragdollJoint(Rcharacter.RightUpperLeg, Rcharacter.RightLowerLeg, "RightKneeRigAttachment", "Hinge", shinProperties)
  191. end)) coroutine.resume(coroutine.create(function()
  192. local footProperties = {
  193. {"LimitsEnabled", true};
  194. {"UpperAngle", 15};
  195. {"LowerAngle", -45};
  196. }
  197. ragdollJoint(Rcharacter.LeftLowerLeg, Rcharacter.LeftFoot, "LeftAnkleRigAttachment", "Hinge", footProperties)
  198. ragdollJoint(Rcharacter.RightLowerLeg, Rcharacter.RightFoot, "RightAnkleRigAttachment", "Hinge", footProperties)
  199. end))
  200. --TODO fix ability for socket to turn backwards whenn ConeConstraints are shipped
  201. coroutine.resume(coroutine.create(function()
  202. ragdollJoint(Rcharacter.UpperTorso, Rcharacter.LeftUpperArm, "LeftShoulderRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
  203. ragdollJoint(Rcharacter.LeftUpperArm, Rcharacter.LeftLowerArm, "LeftElbowRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
  204. ragdollJoint(Rcharacter.UpperTorso, Rcharacter.RightUpperArm, "RightShoulderRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
  205. ragdollJoint(Rcharacter.RightUpperArm, Rcharacter.RightLowerArm, "RightElbowRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
  206. ragdollJoint(Rcharacter.LowerTorso, Rcharacter.LeftUpperLeg, "LeftHipRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
  207. ragdollJoint(Rcharacter.LowerTorso, Rcharacter.RightUpperLeg, "RightHipRigAttachment", "BallSocket") end))
  208.  
  209.  
  210. for i = 0,2 do
  211. coroutine.resume(coroutine.create(function()
  212. for _,child in next,Rcharacter:GetChildren() do
  213. if child:IsA("Accoutrement") then
  214. --Loop through all parts instead of only checking for one to be forwards-compatible in the event
  215. --ROBLOX implements multi-part accessories
  216. for _,part in next,child:GetChildren() do
  217. if part:IsA("BasePart") then part.CanCollide = false
  218.  
  219.  
  220. local attachment1 = part:FindFirstChildOfClass("Attachment")
  221. local attachment0 = getAttachment0(attachment1.Name,Rcharacter)
  222. if attachment0 and attachment1 then
  223. --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
  224. --joints connecting a character are perpetually deleted while the character is dead
  225.  
  226.  
  227. local HatProperties = {
  228. {"LimitsEnabled", true};
  229. {"UpperAngle", 0};
  230. {"LowerAngle", -0};
  231. }
  232.  
  233. coroutine.resume(coroutine.create(function()
  234. wait()
  235. local rg = ragdollJoint(attachment0.Parent, part, ""..attachment1.Name, "Hinge", HatProperties)
  236. end))
  237.  
  238. end
  239. end
  240. end
  241. end
  242. end
  243.  
  244. end))
  245. wait(0.5)
  246. end
  247. for _,v in pairs(Rcharacter:GetChildren()) do
  248. if v:isA("Script") or v:isA("LocalScript") then
  249. v:Destroy()
  250. end
  251. end
  252.  
  253.  
  254. coroutine.resume(coroutine.create(function()
  255. wait(1)
  256. for _,v3 in pairs(game:GetService("Players"):GetChildren()) do
  257. coroutine.resume(coroutine.create(function()
  258. if v3:isA("Player") and v3.Character == Rcharacter then
  259. Rcharacter.Archivable=true
  260. local ORcharacter = Rcharacter:Clone()
  261. --Rcharacter2.Archivable=false
  262. --Rcharacter3.Archivable=false
  263. ORcharacter.Parent = Rcharacter.Parent
  264. local Rhum = ORcharacter:FindFirstChildOfClass("Humanoid")
  265. Rhum.PlatformStand = true
  266. Rhum.Health = Rhum.MaxHealth
  267. Rcharacter:Destroy()
  268. wait()
  269. Rhum.Health = 0
  270. game:GetService("Debris"):AddItem(ORcharacter, 380)
  271.  
  272. end
  273. end))
  274. end
  275.  
  276.  
  277. end))
  278.  
  279.  
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement