Advertisement
InTesting

To R6 V2

Aug 20th, 2021
2,615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.22 KB | None | 0 0
  1. --[[
  2.     ToR6 function
  3.         V1 (With dummy set up): 7280483172
  4.    
  5.         by chl (removing creds aint cool bro)
  6.    
  7.     V2 is mainly script oriented, if you don't want this, check out V1
  8.    
  9.     This module returns a function, so inorder to use it you call it, ex.
  10.        
  11.         require(MODULE)(PLAYER_INSTANCE)
  12. --]]
  13.  
  14. -- assignments
  15. local players = game:GetService('Players')
  16.  
  17. -- functions
  18. local wait = task.wait
  19. local spawn = task.spawn
  20. local V3 = Vector3.new
  21. local CF = CFrame.new
  22.  
  23. -- 1l
  24. function ChangeIndex(a,b)for d,e in next,b do a[d]=e end end
  25. function Create(a)return function(b)local c = Instance.new(a)ChangeIndex(c,b)return c end end
  26.  
  27. -- gen
  28. function FindFirstDescendant(a,...)
  29.     for _,b in next,{...}do
  30.         a = a:FindFirstChild(b)
  31.         if not a then break end
  32.     end
  33.     return a
  34. end
  35. ----------------------------------------------------------------------------------------------------
  36. function CreateDummy()--[[Idk what are yall gonna do with this part so i'lll just make it ugly    ]]
  37. local CurrentStep=1;for _,set in next,{{'Health','Script','local a=script.Parent;local b=a:WaitFo'..
  38. 'rChild("Head")local c=a:WaitForChild("Humanoid")local d=false;function regenHealth()if d then re'..
  39. 'turn end;d=true;while c.Health<c.MaxHealth do local e=wait(1)local f=c.Health;if f>0 and f<c.Max'..
  40. 'Health then local g=0.01*e*c.MaxHealth;f=f+g;c.Health=math.min(f,c.MaxHealth)end end;if c.Health'..
  41. '>c.MaxHealth then c.Health=c.MaxHealth end;d=false end;c.HealthChanged:connect(regenHealth)'};{''..
  42. 'Animate','LocalScript','function waitForChild(a,b)local c=a:findFirstChild(b)if c then return c '..
  43. 'end;while true do c=a.ChildAdded:wait()if c.Name==b then return c end end end;local d=script.Par'..
  44. 'ent;local e=waitForChild(d,"Torso")local f=waitForChild(e,"Right Shoulder")local g=waitForChild('..
  45. 'e,"Left Shoulder")local h=waitForChild(e,"Right Hip")local i=waitForChild(e,"Left Hip")local j=w'..
  46. 'aitForChild(e,"Neck")local k=waitForChild(d,"Humanoid")local l="Standing"local m=""local n=nil;l'..
  47. 'ocal o=nil;local p=nil;local q=1.0;local r={}local s={idle={{id="http://www.roblox.com/asset/?id'..
  48. '=180435571",weight=9},{id="http://www.roblox.com/asset/?id=180435792",weight=1}},walk={{id="http'..
  49. '://www.roblox.com/asset/?id=180426354",weight=10}},run={{id="run.xml",weight=10}},jump={{id="htt'..
  50. 'p://www.roblox.com/asset/?id=125750702",weight=10}},fall={{id="http://www.roblox.com/asset/?id=1'..
  51. '80436148",weight=10}},climb={{id="http://www.roblox.com/asset/?id=180436334",weight=10}},sit={{i'..
  52. 'd="http://www.roblox.com/asset/?id=178130996",weight=10}},toolnone={{id="http://www.roblox.com/a'..
  53. 'sset/?id=182393478",weight=10}},toolslash={{id="http://www.roblox.com/asset/?id=129967390",weigh'..
  54. 't=10}},toollunge={{id="http://www.roblox.com/asset/?id=129967478",weight=10}},wave={{id="http://'..
  55. 'www.roblox.com/asset/?id=128777973",weight=10}},point={{id="http://www.roblox.com/asset/?id=1288'..
  56. '53357",weight=10}},dance1={{id="http://www.roblox.com/asset/?id=182435998",weight=10},{id="http:'..
  57. '//www.roblox.com/asset/?id=182491037",weight=10},{id="http://www.roblox.com/asset/?id=182491065"'..
  58. ',weight=10}},dance2={{id="http://www.roblox.com/asset/?id=182436842",weight=10},{id="http://www.'..
  59. 'roblox.com/asset/?id=182491248",weight=10},{id="http://www.roblox.com/asset/?id=182491277",weigh'..
  60. 't=10}},dance3={{id="http://www.roblox.com/asset/?id=182436935",weight=10},{id="http://www.roblox'..
  61. '.com/asset/?id=182491368",weight=10},{id="http://www.roblox.com/asset/?id=182491423",weight=10}}'..
  62. ',laugh={{id="http://www.roblox.com/asset/?id=129423131",weight=10}},cheer={{id="http://www.roblo'..
  63. 'x.com/asset/?id=129423030",weight=10}}}local t={"dance1","dance2","dance3"}local u={wave=false,p'..
  64. 'oint=false,dance1=true,dance2=true,dance3=true,laugh=false,cheer=false}function configureAnimati'..
  65. 'onSet(v,w)if r[v]~=nil then for x,y in pairs(r[v].connections)do y:disconnect()end end;r[v]={}r['..
  66. 'v].count=0;r[v].totalWeight=0;r[v].connections={}local z=script:FindFirstChild(v)if z~=nil then '..
  67. 'table.insert(r[v].connections,z.ChildAdded:connect(function(c)configureAnimationSet(v,w)end))tab'..
  68. 'le.insert(r[v].connections,z.ChildRemoved:connect(function(c)configureAnimationSet(v,w)end))loca'..
  69. 'l A=1;for x,B in pairs(z:GetChildren())do if B:IsA("Animation")then table.insert(r[v].connection'..
  70. 's,B.Changed:connect(function(C)configureAnimationSet(v,w)end))r[v][A]={}r[v][A].anim=B;local D=B'..
  71. ':FindFirstChild("Weight")if D==nil then r[v][A].weight=1 else r[v][A].weight=D.Value end;r[v].co'..
  72. 'unt=r[v].count+1;r[v].totalWeight=r[v].totalWeight+r[v][A].weight;A=A+1 end end end;if r[v].coun'..
  73. 't<=0 then for A,E in pairs(w)do r[v][A]={}r[v][A].anim=Instance.new("Animation")r[v][A].anim.Nam'..
  74. 'e=v;r[v][A].anim.AnimationId=E.id;r[v][A].weight=E.weight;r[v].count=r[v].count+1;r[v].totalWeig'..
  75. 'ht=r[v].totalWeight+E.weight end end end;function scriptChildModified(c)local w=s[c.Name]if w~=n'..
  76. 'il then configureAnimationSet(c.Name,w)end end;script.ChildAdded:connect(scriptChildModified)scr'..
  77. 'ipt.ChildRemoved:connect(scriptChildModified)for v,w in pairs(s)do configureAnimationSet(v,w)end'..
  78. ';local F="None"local G=0;local H=0;local I=0.3;local J=0.1;local K=0.3;local L=0.75;function sto'..
  79. 'pAllAnimations()local M=m;if u[M]~=nil and u[M]==false then M="idle"end;m=""n=nil;if p~=nil then'..
  80. ' p:disconnect()end;if o~=nil then o:Stop()o:Destroy()o=nil end;return M end;function setAnimatio'..
  81. 'nSpeed(N)if N~=q then q=N;o:AdjustSpeed(q)end end;function keyFrameReachedFunc(O)if O=="End"then'..
  82. ' local P=m;if u[P]~=nil and u[P]==false then P="idle"end;local Q=q;playAnimation(P,0.0,k)setAnim'..
  83. 'ationSpeed(Q)end end;function playAnimation(R,S,T)local U=math.random(1,r[R].totalWeight)local V'..
  84. '=U;local A=1;while U>r[R][A].weight do U=U-r[R][A].weight;A=A+1 end;local E=r[R][A].anim;if E~=n'..
  85. ' then if o~=nil then o:Stop(S)o:Destroy()end;q=1.0;o=T:LoadAnimation(E)o:Play(S)m=R;n=E;if p~=ni'..
  86. 'l then p:disconnect()end;p=o.KeyframeReached:connect(keyFrameReachedFunc)end end;local W=""local'..
  87. ' X=nil;local Y=nil;local Z=nil;function toolKeyFrameReachedFunc(O)if O=="End"then playToolAnimat'..
  88. 'ion(W,0.0,k)end end;function playToolAnimation(R,S,T)local U=math.random(1,r[R].totalWeight)loca'..
  89. 'l V=U;local A=1;while U>r[R][A].weight do U=U-r[R][A].weight;A=A+1 end;local E=r[R][A].anim;if Y'..
  90. '~=E then if X~=nil then X:Stop()X:Destroy()S=0 end;X=T:LoadAnimation(E)X:Play(S)W=R;Y=E;Z=X.Keyf'..
  91. 'rameReached:connect(toolKeyFrameReachedFunc)end end;function stopToolAnimations()local M=W;if Z~'..
  92. '=nil then Z:disconnect()end;W=""Y=nil;if X~=nil then X:Stop()X:Destroy()X=nil end;return M end;f'..
  93. 'unction onRunning(N)if N>0.01 then playAnimation("walk",0.1,k)if n and n.AnimationId=="http://ww'..
  94. 'w.roblox.com/asset/?id=180426354"then setAnimationSpeed(N/14.5)end;l="Running"else if u[m]==nil '..
  95. 'then playAnimation("idle",0.1,k)l="Standing"end end end;function onDied()l="Dead"end;function on'..
  96. 'Jumping()playAnimation("jump",0.1,k)H=I;l="Jumping"end;function onClimbing(N)playAnimation("clim'..
  97. 'b",0.1,k)setAnimationSpeed(N/12.0)l="Climbing"end;function onGettingUp()l="GettingUp"end;functio'..
  98. 'n onFreeFall()if H<=0 then playAnimation("fall",K,k)end;l="FreeFall"end;function onFallingDown()'..
  99. 'l="FallingDown"end;function onSeated()l="Seated"end;function onPlatformStanding()l="PlatformStan'..
  100. 'ding"end;function onSwimming(N)if N>0 then l="Running"else l="Standing"end end;function getTool('..
  101. ')for x,_ in ipairs(d:GetChildren())do if _.className=="Tool"then return _ end end;return nil end'..
  102. ';function getToolAnim(a0)for x,a1 in ipairs(a0:GetChildren())do if a1.Name=="toolanim"and a1.cla'..
  103. 'ssName=="StringValue"then return a1 end end;return nil end;function animateTool()if F=="None"the'..
  104. 'n playToolAnimation("toolnone",J,k)return end;if F=="Slash"then playToolAnimation("toolslash",0,'..
  105. 'k)return end;if F=="Lunge"then playToolAnimation("toollunge",0,k)return end end;function moveSit'..
  106. '()f.MaxVelocity=0.15;g.MaxVelocity=0.15;f:SetDesiredAngle(3.14/2)g:SetDesiredAngle(-3.14/2)h:Set'..
  107. 'DesiredAngle(3.14/2)i:SetDesiredAngle(-3.14/2)end;local a2=0;function move(a3)local a4=1;local a'..
  108. '5=1;local a6=a3-a2;a2=a3;local a7=0;local a8=false;if H>0 then H=H-a6 end;if l=="FreeFall"and H<'..
  109. '=0 then playAnimation("fall",K,k)elseif l=="Seated"then playAnimation("sit",0.5,k)return elseif '..
  110. 'l=="Running"then playAnimation("walk",0.1,k)elseif l=="Dead"or l=="GettingUp"or l=="FallingDown"'..
  111. 'or l=="Seated"or l=="PlatformStanding"then stopAllAnimations()a4=0.1;a5=1;a8=true end;if a8 then'..
  112. ' desiredAngle=a4*math.sin(a3*a5)f:SetDesiredAngle(desiredAngle+a7)g:SetDesiredAngle(desiredAngle'..
  113. '-a7)h:SetDesiredAngle(-desiredAngle)i:SetDesiredAngle(-desiredAngle)end;local a0=getTool()if a0 '..
  114. 'and a0:FindFirstChild("Handle")then animStringValueObject=getToolAnim(a0)if animStringValueObjec'..
  115. 't then F=animStringValueObject.Value;animStringValueObject.Parent=nil;G=a3+.3 end;if a3>G then G'..
  116. '=0;F="None"end;animateTool()else stopToolAnimations()F="None"Y=nil;G=0 end end;k.Died:connect(on'..
  117. 'Died)k.Running:connect(onRunning)k.Jumping:connect(onJumping)k.Climbing:connect(onClimbing)k.Get'..
  118. 'tingUp:connect(onGettingUp)k.FreeFalling:connect(onFreeFall)k.FallingDown:connect(onFallingDown)'..
  119. 'k.Seated:connect(onSeated)k.PlatformStanding:connect(onPlatformStanding)k.Swimming:connect(onSwi'..
  120. 'mming)game.Players.LocalPlayer.Chatted:connect(function(a9)local aa=""if a9=="/e dance"then aa=t'..
  121. '[math.random(1,#t)]elseif string.sub(a9,1,3)=="/e "then aa=string.sub(a9,4)elseif string.sub(a9,'..
  122. '1,7)=="/emote "then aa=string.sub(a9,8)end;if l=="Standing"and u[aa]~=nil then playAnimation(aa,'..
  123. '0.1,k)end end)local ab=game:service("RunService")playAnimation("idle",0.1,k)l="Standing"task.spa'..
  124. 'wn(function()while d.Parent~=nil do local x,a3=wait(0.1)move(a3)end end)local ac=game.Players.Lo'..
  125. 'calPlayer;function waitForDescendant(a,...)for x,ad in next,{...}do a=a:WaitForChild(ad,1/0)end;'..
  126. 'return a end;if not ac then return end;local ae=waitForDescendant(ac,\'PlayerScripts\',\'PlayerM'..
  127. 'odule\',\'ControlModule\')local af=ae:Clone()require(af)'};{'RunCmd','AddStep'};{'Create',{'Model';
  128. {Name='Dummy';Parent=script}}};{'GetClonedMember',{'Health';{Disabled=1>0},{Parent={'Dummy'}};};{'A'
  129. ..'nimate';{Disabled=1>0},{Parent={'Dummy'}}}};{'Create',{'Part',{CFrame=CF(0,4.5,.5);Name='He\97d';
  130. Size=V3(2,1,1)},{Parent={'Dummy'}}},{'SpecialMesh',{Scale=V3(5/4,5/4,5/4)},{Parent={'Dummy','Head'}}
  131. },{'Decal',{Name='face';Texture='rbxasset://textures/face.png'},{Parent={'Dummy','Head'}}},{'Atta'..
  132. 'chment',{CFrame=CF(0,.6,0);Name='HairAttachment'},{Parent={'Dummy','Head'}}},{'Attachment',{CFrame=
  133. CF(0,.6,0);Name='HatAttachment'},{Parent={'Dummy','Head'}};},{'Attachment',{CFrame=CF(0,0,-.6);Name=
  134. 'FaceFrontAttachment'},{Parent={'Dummy','Head'}}},{'Attachment',{Name='\70\97ceCenterAttachment';},{
  135. Parent={'Dummy','Head'}}},{'Part',{CFrame=CF(-1.5,3,.5);Name='Left Arm';Size=V3(1,2,1)},{Parent={'D'
  136. ..'ummy'}}},{'Attachment',{CFrame=CF(0,1,0);Name='LeftShoulderAttachment'},{Parent={'Dummy','Left'..
  137. ' Arm'}}},{'Part',{CFrame=CF(1.5,3,.5);Name='Right Arm';Size=V3(1,2,1)},{Parent={'Dummy'}}},{'Att'..
  138. 'achment',{CFrame=CF(0,1,0);Name='RightShoulderAttachment'},{Parent={'Dummy','Right Arm'}}},{'Part',
  139. {CFrame=CF(-.5,1,.5);Name='Left Leg';Size=V3(1,2,1)},{Parent={'Dummy'}}},{'Part',{CFrame=CF(.5,1,.5)
  140. ;Name='Right Leg';Size=V3(1,2,1)},{Parent={'Dummy'}}},{'Part',{CFrame=CF(0,3,1/2);Name='Torso';Size=
  141. V3(2,2,1)},{Parent={'Dummy'}}},{'Decal',{Name='roblox'},{Parent={'Dummy','Torso'}};},{'Attachment',{
  142. CFrame=CF(0,1,0);Name='NeckAttachment'},{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(0,0,-.5
  143. );Name='BodyFrontAttachment'},{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(0,0,.5);Name='Bo'
  144. ..'dyBackAttachment'},{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(-1,1,0);Name='LeftColl'..
  145. 'arAttachment'},{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(1,1,0);Name='RightCollarAtta'..
  146. 'chment'},{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(0,-1,-.5);Name='WaistFrontAttachment'
  147. },{Parent={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(0,-1,0);Name='WaistCenterAttachment'},{Parent
  148. ={'Dummy','Torso'}}},{'Attachment',{CFrame=CF(0,-1,.5);Name='WaistBackAttachment'},{Parent={'Dummy',
  149. 'Torso'}}},{'Motor6D',{Name='Right Shoulder';MaxVelocity=.1;C0=CF(1,.5,0,0,0,1,0,1,0,-1,0,0);C1=CF(-
  150. .5,.5,0,0,0,1,0,1,0,-1,0,0)},{Part1={'Dummy','Right Arm'};Parent={'Dummy','Torso'};Part0={'\68ummy',
  151. 'Torso'}}},{'Motor6D',{Name='Left Shoulder';MaxVelocity=.1;C0=CF(-1,1/2,0,0,0,-1,0,1,0,1,0,0);C1=CF(
  152. .5,.5,0,0,0,-1,0,1,0,1,0,0)},{Part1={'Dummy','Left Arm'};Parent={'Dummy','Torso'};Part0={'Dummy','T'
  153. ..'orso'}}},{'Motor6D',{Name='Right Hip';MaxVelocity=.1;C0=CF(1,-1,0,0,0,1,0,1,0,-1,0,0);C1=CF(.5,1,
  154. 0,0,0,1,0,1,0,-1,0,0)},{Part1={'Dummy','Right Leg'};Parent={'Dummy','Torso'};Part0={'Dummy','Tors'..
  155. 'o'}}},{'Motor6D',{Name='Left Hip';MaxVelocity=.1;C0=CF(-1,-1,0,0,0,-1,0,1,0,1,0,0);C1=CF(-.5,1,0,0,
  156. 0,-1,0,1,0,1,0,0)},{Part1={'Dummy','Left Leg'};Parent={'Dummy','Torso'};Part0={'Dummy','Torso'}};},{
  157. 'Motor6D',{Name='Neck';MaxVelocity=.1;C0=CF(0,1,0,-1,0,0,0,0,1,0,1,0);C1=CF(0,-.5,0,-1,0,0,0,0,1,0,1
  158. ,0)},{Part1={'Dummy','Head'};Parent={'Dummy','Torso'};Part0={'Dummy','Torso'}}},{'\72um\97noid',{},{
  159. Parent={'Dummy'}}},{'Animator',{},{Parent={'Dummy','Humanoid'}}},{'Part',{CFrame=CF(0,3,.5);Name='H'
  160. ..'umanoidRootPart';Size=V3(2,2,1);Transparency=1},{Parent={'Dummy'}}},{'Motor6D',{Name='RootJoint';
  161. MaxVelocity=.1;C0=CF(0,0,0,-1,0,0,0,0,1,0,1,0);C1=CF(0,0,0,-1,0,0,0,0,1,0,1,0)},{Part1={'Dummy','To'
  162. ..'rso'};Parent={'Dummy','HumanoidRootPart'};Part0={'Dummy','HumanoidRootPart'}}},{'\83tringValue',{
  163. Name='idle'},{Parent={'Dummy','Animate'}}},{'Animation',{AnimationId='http://www.roblox.com/asset'..
  164. '/?id=180435571';Name='Animation1'},{Parent={'Dummy','Animate','idle'}}},{'NumberValue',{Name='We'..
  165. 'ight';Value=9},{Parent={'Dummy','Animate','idle','Animation1'}}},{'Animation',{AnimationId='http'..
  166. '://www.roblox.com/asset/?id=180435792';Name='Animation2'},{Parent={'Dummy','Animate','idle'}}},{'N'
  167. ..'umberValue',{Name='Weight';Value=1},{Parent={'Dummy','Animate','idle','Animation2'}}},{'String'..
  168. 'Value',{Name='walk'},{Parent={'Dummy','Animate'}}},{'Animation',{AnimationId='http://www.roblox.'..
  169. 'com/asset/?id=180426354';Name='WalkAnim'},{Parent={'Dummy','Animate','walk'}}},{'StringValue',{Name
  170. ='run'},{Parent={'Dummy','Animate'}}},{'Animation',{AnimationId='http://www.roblox.com/asset/?id='..
  171. '180426354';Name='RunAnim'},{Parent={'Dummy','Animate','run'}}},{'StringValue',{Name='jump'},{Parent
  172. ={'Dummy','Animate'}}},{'Animation',{AnimationId='http://www.roblox.com/asset/?id=12575070\50';Name=
  173. 'JumpAnim'},{Parent={'Dummy','Animate','jump'}}},{'StringValue',{Name='climb'},{Parent={'Dummy','An'
  174. ..'imate'}}},{'Animation',{AnimationId='rbxassetid://180436334';Name='ClimbAnim';},{Parent={'Dummy',
  175. 'Animate','climb'}}},{'StringValue',{Name='toolnone'},{Parent={'Dummy','Animate'}}},{'\65nimation',{
  176. AnimationId='http://www.roblox.com/asset/?id=182393478';Name='ToolNoneAnim'},{Parent={'Dummy','An'..
  177. 'imate','toolnone'}}},{'StringValue',{Name='fall'},{Parent={'Dummy','Animate'}}},{'Animation',{['An'
  178. ..'imationId']='http://www.roblox.com/asset/?id=180436148';Name='FallAnim'},{Parent={'Dummy','Ani'..
  179. 'mate','fall'}}},{'StringValue',{Name='sit'},{Parent={'Dummy','Animate'}}},{'Animation',{AnimationId
  180. ='http://www.roblox.com/asset/?id=178130996';Name='SitAnim'},{Parent={'Dummy','Animate','sit'}}}}}do
  181. if set[1]=='\82unCmd'then if'\65\100\100\83\116\101\112'==set[2]then CurrentStep+=1 end continue;end
  182. if CurrentStep==(1+(0*#'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww'))then
  183. assert(script:FindFirstChild(set[1]),'Missing member: Expected '..set[2]..' '..'named '..set[1]..'w'
  184. ..'\105\116\104\32\115\111\117\114ce\58\32'..set[1+1+1])elseif CurrentStep==1+1 then local Cmd=set[1
  185. ];if Cmd=='\67\114\101\97\116\101'then for it,subset in next,set do if it==(1+(0))then continue end;
  186. local ins=Create(subset[1])(subset[2]);if subset[1+1+1]and type(subset[1+1+1])=='\116\97\98\108\101'
  187. then for a,c in next,subset[1+1+1]do subset[1+1+0][a]=FindFirstDescendant(script,unpack(c));end;end;
  188. ChangeIndex(ins,subset[2])end;elseif Cmd=='GetClonedMe\109\98\101\114'then for it,subset in next,set
  189. do if it==1 then continue end local Clone=script:FindFirstChild(subset[1+0*#'wwwwwwwwwww']):Clone();
  190. ChangeIndex(Clone,subset[2]);if subset[3]and type(subset[3])=='table'then for a,c in next,subset[1+2
  191. ]do subset[1+1][a]=FindFirstDescendant(script,unpack(c));end;end;ChangeIndex(Clone,subset[1+1+0*#'w'
  192. ]);end;end;end;end;return script:FindFirstChild('\68\117\109\109\121'..(''):rep(#'wwwwwwwwww'));end;
  193.  
  194. function GetDummy()
  195.     local Result = script:FindFirstChild('Dummy')
  196.    
  197.     if not Result then
  198.         Result = CreateDummy()
  199.     end
  200.    
  201.     return Result
  202. end
  203.  
  204. function ToR6(player)
  205.     assert(typeof(player)=='Instance','Bad argument: Expected value type Instance, got '.. typeof(player))
  206.     assert(player:IsA'Player','Bad argument: Expected ClassName Player, got' .. player.ClassName)
  207.     local character = assert(player.Character,'Property Player\'s character is nil.')
  208.     assert(character.Parent,'Character\'s parent is nil.')
  209.     local humanoidRootPart = assert(character:FindFirstChild('HumanoidRootPart'),'No HumanoidRootPart parented under character')
  210.     assert(humanoidRootPart:IsA('Part'),'HumanoidRootPart not a Part. Possible that multiple children are named "HumanoidRootPart"')
  211.    
  212.    
  213.    
  214.     local description = players:GetHumanoidDescriptionFromUserId(player.UserId)
  215.     local cloneDummy = GetDummy():Clone()
  216.     local originalCFrame = humanoidRootPart.CFrame
  217.     local originalParent = character.Parent
  218.    
  219.    
  220.     for _,a in next,character:GetChildren()do
  221.         if a:IsA('LuaSourceContainer')then
  222.             a.Disabled = true
  223.         end
  224.        
  225.         a:Destroy()
  226.     end
  227.    
  228.     character.Parent = nil
  229.  
  230.     for _,a in next,cloneDummy:GetChildren()do
  231.         a.Parent = character
  232.     end
  233.    
  234.     local humanoidRootPart = character.HumanoidRootPart
  235.    
  236.     humanoidRootPart.CFrame = originalCFrame
  237.    
  238.     character.PrimaryPart = humanoidRootPart
  239.     character.Parent = originalParent
  240.  
  241.     character.Animate.Disabled = false
  242.     character.Health.Disabled = false
  243.  
  244.  
  245.     local humanoid = character:FindFirstChildWhichIsA'Humanoid'
  246.     humanoid:ApplyDescription(description)
  247.    
  248.     spawn(function()
  249.         humanoid.Died:Wait()
  250.  
  251.         wait(players.RespawnTime)
  252.  
  253.         player:LoadCharacter()
  254.     end)
  255. end
  256.  
  257. -- return
  258. return ToR6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement