Dark_Agent

PatchmaHUB-EDITIONv2

Jun 8th, 2024
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 72.14 KB | Gaming | 0 0
  1. --[[
  2.     patchma hub by MyWorld
  3.     Immortality Lord edition
  4.  
  5.     required accessories:
  6.         head:
  7.             17375337078 or 17270164442
  8.         body:
  9.             17270178857,17270001635,17269952801,17269983359,17269998373
  10.         wings:
  11.             17270231731,17270225913
  12.         sword:
  13.             17326812233,17326800544
  14.  
  15.     based on patchma hub version 38
  16. ]]
  17.  
  18. local osclock=os.clock
  19. local tspawn=task.spawn
  20. local twait=task.wait
  21. local schar=string.char
  22. local ssub=string.sub
  23. local sfind=string.find
  24. local supper=string.upper
  25. local mrandom=math.random
  26. local sin=math.sin
  27. local cos=math.cos
  28. local abs=math.abs
  29. local rad=math.rad
  30. local min=math.min
  31. local clamp=math.clamp
  32. local tinsert=table.insert
  33. local tclear=table.clear
  34. local tclone=table.clone
  35. local tfind=table.find
  36. local tunpack=table.unpack
  37.  
  38. --the script doesnt have to read global varaibles every time to get them
  39. --why not have them saved in local varaibles for faster access times
  40. local next=next
  41. local pcall=pcall
  42. local xpcall=xpcall
  43. local type=type
  44. local typeof=typeof
  45. local game=game
  46.  
  47. local i=Instance.new
  48. local v2=Vector2.new
  49. local v3=Vector3.new
  50. local c3=Color3.new
  51. local cf=CFrame.new
  52. local cfl=CFrame.lookAt
  53. local angles=CFrame.Angles
  54. local u2=UDim2.new
  55. local e=Enum
  56. local rp=RaycastParams.new
  57. local cs=ColorSequence.new
  58. local csk=ColorSequenceKeypoint.new
  59.  
  60. local sine=osclock()
  61. local deltaTime=0
  62. local v3_0=v3(0,0,0)
  63. local v3_101=v3(1,0,1)
  64. local v3_010=v3(0,1,0)
  65. local v3_001=v3(0,0,1)
  66. local cf_0=cf(0,0,0)
  67. local v3_xz=v3_101*10
  68. local v3_xzL=v3_101*250.1
  69. local v3_net=v3_010*25.01
  70.  
  71. local function rs(l)
  72.     l=l or mrandom(8,15)
  73.     local s=""
  74.     for i=1,l do
  75.         if mrandom(1,2)==1 then
  76.             s=s..schar(mrandom(65,90))
  77.         else
  78.             s=s..schar(mrandom(97,122))
  79.         end
  80.     end
  81.     return s
  82. end
  83.  
  84. --it runs even faster if u call __index and __newindex of metatables of userdata directly
  85. local function getMetamethodFromErrorStack(userdata,f,test)
  86.     local ret=nil
  87.     xpcall(f,function()
  88.         ret=debug.info(2,"f")
  89.     end,userdata,nil,0)
  90.     if (type(ret)~="function") or not test(ret) then
  91.         return f
  92.     end
  93.     return ret
  94. end
  95. local insSet=getMetamethodFromErrorStack(game,function(a,b,c) a[b]=c end,function(f) local a=i("Folder") local b=rs() f(a,"Name",b) return a.Name==b end)
  96. local insGet=getMetamethodFromErrorStack(game,function(a,b) return a[b] end,function(f) local a=i("Folder") local b=rs() a.Name=b return f(a,"Name")==b end)
  97. local cfGet=getMetamethodFromErrorStack(cf_0,function(a,b) return a[b] end,function(f) return f(cf(1,2,3),"Position")==v3(1,2,3) end)
  98. local cfMul=getMetamethodFromErrorStack(cf_0,function(a,b) return a*b end,function(f) return angles(1,2,3)*angles(1,2,3)==f(angles(1,2,3),angles(1,2,3)) end)
  99. local cfAdd=getMetamethodFromErrorStack(cf_0,function(a,b) return a+b end,function(f) return cf(1,2,3)+v3(1,2,3)==f(cf(1,2,3),v3(1,2,3)) end)
  100. local v3Get=getMetamethodFromErrorStack(v3_0,function(a,b) return a[b] end,function(f) return v3(1,2,3).Unit==f(v3(1,2,3),"Unit") end)
  101. --multiplying and adding vector3 is faster if you use the * and + operators
  102.  
  103. --no need to index instances every time to call their functions
  104. local Clone=insGet(game,"Clone")
  105. local ClearAllChildren=insGet(game,"ClearAllChildren")
  106. local Destroy=insGet(game,"Destroy")
  107. local IsA=insGet(game,"IsA")
  108. local FindFirstChildOfClass=insGet(game,"FindFirstChildOfClass")
  109. local FindFirstChildWhichIsA=insGet(game,"FindFirstChildWhichIsA")
  110. local GetChildren=insGet(game,"GetChildren")
  111. local GetDescendants=insGet(game,"GetDescendants")
  112. local IsDescendantOf=insGet(game,"IsDescendantOf")
  113. local GetPropertyChangedSignal=insGet(game,"GetPropertyChangedSignal")
  114.  
  115. --findfirstchildofclass faster than getservice
  116. local plrs=FindFirstChildOfClass(game,"Players")
  117. local rus=FindFirstChildOfClass(game,"RunService")
  118. local ws=FindFirstChildOfClass(game,"Workspace")
  119. local uis=FindFirstChildOfClass(game,"UserInputService")
  120. local gs=FindFirstChildOfClass(game,"GuiService")
  121. local lp=insGet(plrs,"LocalPlayer")
  122. local pg=FindFirstChildOfClass(lp,"PlayerGui")
  123. local mouse=insGet(lp,"GetMouse")(lp)
  124. local stepped=insGet(rus,"Stepped")
  125. local heartbeat=insGet(rus,"Heartbeat")
  126. local renderstepped=insGet(rus,"RenderStepped")
  127.  
  128. local GetPlayers=insGet(plrs,"GetPlayers")
  129. local Raycast=insGet(ws,"Raycast")
  130. local Connect=heartbeat.Connect
  131. local Disconnect=Connect(GetPropertyChangedSignal(game,"CreatorId"),type).Disconnect
  132. local Wait=heartbeat.Wait
  133. local GetMouseLocation=insGet(uis,"GetMouseLocation")
  134. local GetFocusedTextBox=insGet(uis,"GetFocusedTextBox")
  135. local GetMouseDelta=insGet(uis,"GetMouseDelta")
  136. local IsMouseButtonPressed=insGet(uis,"IsMouseButtonPressed")
  137. local IsKeyDown=insGet(uis,"IsKeyDown")
  138.  
  139. local Inverse=cfGet(cf_0,"Inverse")
  140. local Lerp=cfGet(cf_0,"Lerp")
  141.  
  142. local guiTheme={
  143.     guiTitle="patchma hub IL edition",
  144.     windowTitleColor=c3(0.7,0.7,0.7),
  145.     windowTopColor=c3(0,0,0),
  146.     windowBottomColor=c3(0.05,0.05,0.05),
  147.     windowMinimizedSize={X=220,Y=22},
  148.     windowRegularSize={X=220,Y=263},
  149.     buttonsTextColor=c3(0.560784,0.560784,0.560784),
  150.     labelsTextColor=c3(0.3,0.3,0.3),
  151.     listTopColor=c3(0,0,0),
  152.     listBottomColor=c3(0.07,0.07,0.07)
  153. }
  154.  
  155. local accessorylimbs={
  156.     {meshid="17269636541",textureid="",C0=cf_0,Name="Torso"},
  157.     {meshid="17269753087",textureid="",C0=angles(0,3.14,0),Name="Head"},
  158.     {meshid="17375312569",textureid="",C0=cf(1.50995803e-08,-1.07200003,-0.100000001,-1,0,1.50995803e-07,0,1,0,-1.50995803e-07,0,-1),Name="Head"},
  159.     {meshid="17269487439",textureid="",C0=angles(0,0,1.5707963267948966),Name="Left Arm"},
  160.     {meshid="17269487439",textureid="",C0=angles(0,0,1.5707963267948966),Name="Right Arm"},
  161.     {meshid="17269487439",textureid="",C0=angles(0,0,1.5707963267948966),Name="Left Leg"},
  162.     {meshid="17269487439",textureid="",C0=angles(0,0,1.5707963267948966),Name="Right Leg"}
  163. }
  164.  
  165. local function gp(p,n,cl)
  166.     for i,v in next,GetChildren(p) do
  167.         if IsA(v,cl) and (insGet(v,"Name")==n) then
  168.             return v
  169.         end
  170.     end
  171.     return nil
  172. end
  173. local function timegp(p,n,c,t)
  174.     t=osclock()+t
  175.     while t>osclock() do
  176.         local r=gp(p,n,c)
  177.         if r then
  178.             return r
  179.         end
  180.         Wait(stepped)
  181.     end
  182.     return nil
  183. end
  184. local function getNetlessVelocity(realVel)
  185.     --if true then return v3_0 end
  186.     --if true then return realVel end
  187.     --if true then return v3_net end
  188.     if v3Get(realVel,"Magnitude")>25.01 then
  189.         return v3Get(realVel,"Unit")*v3_xzL+v3_net
  190.     end
  191.     return realVel*v3_xz+v3_net
  192. end
  193. local sft=1/45
  194. local function getFallingTime(Ypos,destY,gravity)
  195.     local velY=25.01
  196.     local fallingTime=0
  197.     gravity=gravity*sft
  198.     while (Ypos>destY) or (velY>0) do
  199.         fallingTime=fallingTime+sft
  200.         velY=velY-gravity
  201.         Ypos=Ypos+(velY*sft)
  202.     end
  203.     return fallingTime
  204. end
  205. local function getMeshOfPart(v)
  206.     if IsA(v,"MeshPart") then
  207.         return insGet(v,"MeshId"), insGet(v,"TextureID")
  208.     elseif IsA(v,"BasePart") then
  209.         v=FindFirstChildOfClass(v,"SpecialMesh")
  210.         if v then
  211.             return insGet(v,"MeshId"), insGet(v,"TextureId")
  212.         end
  213.     end
  214.     return nil, nil
  215. end
  216. local function makeplaceholder(v)
  217.     if typeof(v)~="Instance" then
  218.         return nil
  219.     end
  220.     if not insGet(v,"Archivable") then
  221.         insSet(v,"Archivable",true)
  222.     end
  223.     v=Clone(v)
  224.     for i,v in next,GetChildren(v) do
  225.         if IsA(v,"SpecialMesh") then
  226.             insSet(v,"Name",rs())
  227.             ClearAllChildren(v)
  228.         else
  229.             Destroy(v)
  230.         end
  231.     end
  232.     insSet(v,"Name",rs())
  233.     insSet(v,"Anchored",true)
  234.     insSet(v,"CanCollide",false)
  235.     insSet(v,"Transparency",0.25)
  236.     insSet(v,"Parent",ws)
  237.     return v
  238. end
  239. local function emptyfunction() end
  240.  
  241. local i1=i("Frame")
  242. local i2=i("Frame")
  243. local i3=i("Frame")
  244. local i4=i("ScrollingFrame")
  245. local i5=i("UIListLayout")
  246. local i6=i("UIGradient")
  247. local i7=i("TextBox")
  248. local i8=i("TextButton")
  249. local i9=i("UIGradient")
  250. local i10=i("ScreenGui")
  251. insSet(i1,"AnchorPoint",v2(0.5,0))
  252. insSet(i1,"Active",true)
  253. insSet(i1,"BorderSizePixel",0)
  254. insSet(i1,"ClipsDescendants",true)
  255. insSet(i1,"Position",u2(0.5,0,0.5,guiTheme.windowRegularSize.Y/-2))
  256. insSet(i1,"Size",u2(0,guiTheme.windowRegularSize.X,0,guiTheme.windowRegularSize.Y))
  257. insSet(i1,"Name",rs())
  258. insSet(i1,"Parent",i10)
  259. insSet(i2,"BackgroundColor3",c3(1,1,1))
  260. insSet(i2,"BorderSizePixel",0)
  261. insSet(i2,"Size",u2(0,guiTheme.windowRegularSize.X,0,guiTheme.windowRegularSize.Y))
  262. insSet(i2,"Name",rs())
  263. insSet(i2,"Parent",i1)
  264. insSet(i3,"BackgroundColor3",c3(1,1,1))
  265. insSet(i3,"BorderSizePixel",0)
  266. insSet(i3,"Position",u2(0,5,0,guiTheme.windowMinimizedSize.Y-2))
  267. insSet(i3,"Size",u2(1,-10,0,guiTheme.windowRegularSize.Y-guiTheme.windowMinimizedSize.Y-3))
  268. insSet(i3,"Name",rs())
  269. insSet(i3,"Parent",i2)
  270. insSet(i4,"Active",true)
  271. insSet(i4,"BackgroundTransparency",1)
  272. insSet(i4,"BorderSizePixel",0)
  273. insSet(i4,"Size",u2(1,-3,1,0))
  274. insSet(i4,"AutomaticCanvasSize",e.AutomaticSize.Y)
  275. insSet(i4,"CanvasSize",u2(0,0,0,0))
  276. insSet(i4,"ScrollBarThickness",7)
  277. insSet(i4,"Name",rs())
  278. insSet(i4,"Parent",i3)
  279. insSet(i5,"Name",rs())
  280. insSet(i5,"Parent",i4)
  281. insSet(i5,"SortOrder",e.SortOrder.LayoutOrder)
  282. insSet(i6,"Name",rs())
  283. insSet(i6,"Parent",i3)
  284. insSet(i6,"Color",cs({csk(0,guiTheme.listTopColor),csk(1,guiTheme.listBottomColor)}))
  285. insSet(i6,"Rotation",90)
  286. insSet(i7,"Font",e.Font.SourceSans)
  287. insSet(i7,"FontSize",e.FontSize.Size18)
  288. insSet(i7,"ClearTextOnFocus",false)
  289. insSet(i7,"Text",guiTheme.guiTitle)
  290. insSet(i7,"TextColor3",guiTheme.windowTitleColor)
  291. insSet(i7,"TextSize",16)
  292. insSet(i7,"AnchorPoint",v2(0.5,0))
  293. insSet(i7,"BackgroundTransparency",1)
  294. insSet(i7,"Position",u2(0.5,0,0,guiTheme.windowMinimizedSize.Y/2))
  295. insSet(i7,"Name",rs())
  296. insSet(i7,"Parent",i2)
  297. insSet(i8,"AnchorPoint",v2(1,0))
  298. insSet(i8,"BackgroundTransparency",1)
  299. insSet(i8,"Position",u2(1,0,0,0))
  300. insSet(i8,"Size",u2(0,40,0,guiTheme.windowMinimizedSize.Y))
  301. insSet(i8,"Name",rs())
  302. insSet(i8,"Parent",i2)
  303. insSet(i8,"Font",e.Font.SourceSans)
  304. insSet(i8,"FontSize",e.FontSize.Size18)
  305. insSet(i8,"Text","-")
  306. insSet(i8,"TextColor3",c3(1,1,1))
  307. insSet(i8,"TextSize",16)
  308. insSet(i9,"Name",rs())
  309. insSet(i9,"Parent",i2)
  310. insSet(i9,"Color",cs({csk(0,guiTheme.windowTopColor),csk(1,guiTheme.windowBottomColor)}))
  311. insSet(i9,"Rotation",90)
  312. insSet(i10,"ZIndexBehavior",e.ZIndexBehavior.Sibling)
  313. insSet(i10,"IgnoreGuiInset",true)
  314. insSet(i10,"ResetOnSpawn",false)
  315. insSet(i10,"DisplayOrder",2147483647)
  316. insSet(i10,"Name",rs())
  317. local guimin=false
  318. local minloop=false
  319. local i1X=guiTheme.windowRegularSize.X
  320. local i1Y=guiTheme.windowRegularSize.Y
  321. local i1Xdest=i1X
  322. local i1Ydest=i1Y
  323. Connect(insGet(i8,"MouseButton1Click"),function()
  324.     guimin = not guimin
  325.     if guimin then
  326.         i1Xdest=guiTheme.windowMinimizedSize.X
  327.         i1Ydest=guiTheme.windowMinimizedSize.Y
  328.     else
  329.         i1Xdest=guiTheme.windowRegularSize.X
  330.         i1Ydest=guiTheme.windowRegularSize.Y
  331.     end
  332.     if minloop then
  333.         return
  334.     end
  335.     minloop=true
  336.     insSet(i3,"Visible",true)
  337.     sine=osclock()
  338.     local lastsine=sine
  339.     while true do
  340.         sine=osclock()
  341.         local deltaTime=(sine-lastsine)*10
  342.         lastsine=sine
  343.         local difX=i1Xdest-i1X
  344.         local difY=i1Ydest-i1Y
  345.         if (abs(difY)<=1) and (abs(difX)<=1) then
  346.             i1X=i1Xdest
  347.             i1Y=i1Ydest
  348.             insSet(i1,"Size",u2(0,i1X,0,i1Y))
  349.             break
  350.         end
  351.         i1X=i1X+difX*deltaTime
  352.         i1Y=i1Y+difY*deltaTime
  353.         insSet(i1,"Size",u2(0,i1X,0,i1Y))
  354.         twait()
  355.     end
  356.     insSet(i3,"Visible",not guimin)
  357.     minloop=false
  358. end)
  359. local function Draggable(window,obj)
  360.     local MB1enum = e.UserInputType.MouseButton1
  361.     local TOUCHenum = e.UserInputType.Touch
  362.     obj = obj or window
  363.     local activeEntered = 0
  364.     local mouseStart = nil
  365.     local dragStart = nil
  366.     local inputbegancon = nil
  367.     local rendersteppedcon = nil
  368.     local inputendedcon = nil
  369.     local function inputendedf(a)
  370.         a=insGet(a,"UserInputType")
  371.         if (a==MB1enum) or (a==TOUCHenum) then
  372.             Disconnect(rendersteppedcon)
  373.             Disconnect(inputendedcon)
  374.         end
  375.     end
  376.     local function rendersteppedf()
  377.         local off = GetMouseLocation(uis)-mouseStart
  378.         insSet(window,"Position",dragStart+u2(0,off.X,0,off.Y))
  379.     end
  380.     local function inputbeganf(a)
  381.         a=insGet(a,"UserInputType")
  382.         if ((a==MB1enum) or (a==TOUCHenum)) and (activeEntered==0) and not GetFocusedTextBox(uis) then
  383.             mouseStart=GetMouseLocation(uis)
  384.             dragStart=insGet(window,"Position")
  385.             if rendersteppedcon then Disconnect(rendersteppedcon) end
  386.             rendersteppedcon = Connect(renderstepped,rendersteppedf)
  387.             if inputendedcon then Disconnect(inputendedcon) end
  388.             inputendedcon = Connect(insGet(uis,"InputEnded"),inputendedf)
  389.         end
  390.     end
  391.     Connect(insGet(obj,"MouseEnter"),function()
  392.         if inputbegancon then Disconnect(inputbegancon) end
  393.         inputbegancon = Connect(insGet(uis,"InputBegan"),inputbeganf)
  394.     end)
  395.     Connect(insGet(obj,"MouseLeave"),function()
  396.         Disconnect(inputbegancon)
  397.     end)
  398.     local function ondes(d)
  399.         if IsA(d,"GuiObject") then
  400.             local thisEntered = false
  401.             local thisAdded = false
  402.             local con0 = Connect(insGet(d,"MouseEnter"),function()
  403.                 thisEntered = true
  404.                 if (not thisAdded) and insGet(d,"Active") then
  405.                     activeEntered = activeEntered + 1
  406.                     thisAdded = true
  407.                 end
  408.             end)
  409.             local con1 = Connect(insGet(d,"MouseLeave"),function()
  410.                 thisEntered = false
  411.                 if thisAdded then
  412.                     activeEntered = activeEntered - 1
  413.                     thisAdded = false
  414.                 end
  415.             end)
  416.             local con2 = Connect(GetPropertyChangedSignal(d,"Active"),function()
  417.                 if thisEntered then
  418.                     if thisAdded and not insGet(d,"Active") then
  419.                         activeEntered = activeEntered - 1
  420.                         thisAdded = false
  421.                     elseif insGet(d,"Active") and not thisAdded then
  422.                         activeEntered = activeEntered + 1
  423.                         thisAdded = true
  424.                     end
  425.                 end
  426.             end)
  427.             local con3 = nil
  428.             con3 = Connect(insGet(d,"AncestryChanged"),function()
  429.                 if not IsDescendantOf(d,window) then
  430.                     if thisEntered then
  431.                         activeEntered = activeEntered - 1
  432.                     end
  433.                     Disconnect(con0)
  434.                     Disconnect(con1)
  435.                     Disconnect(con2)
  436.                     Disconnect(con3)
  437.                 end
  438.             end)
  439.         end
  440.     end
  441.     Connect(insGet(window,"DescendantAdded"),ondes)
  442.     for i,v in next,GetDescendants(window) do
  443.         ondes(v)
  444.     end
  445. end
  446. local function btn(txt, f)
  447.     local i1=i("TextBox")
  448.     local i2=i("TextButton")
  449.     insSet(i1,"Font",e.Font.SourceSans)
  450.     insSet(i1,"FontSize",e.FontSize.Size14)
  451.     insSet(i1,"Text",txt)
  452.     insSet(i1,"ClearTextOnFocus",false)
  453.     insSet(i1,"Position",u2(0.5,0,0.5,0))
  454.     insSet(i1,"TextColor3",guiTheme.buttonsTextColor)
  455.     insSet(i1,"Name",rs())
  456.     insSet(i1,"Parent",i2)
  457.     insSet(i2,"BackgroundTransparency",1)
  458.     insSet(i2,"TextTransparency",1)
  459.     insSet(i2,"Size",u2(1,0,0,14))
  460.     insSet(i2,"Name",rs())
  461.     if f then
  462.         Connect(insGet(i2,"MouseButton1Click"),f)
  463.     end
  464.     insSet(i2,"Parent",i4)
  465.     return i1
  466. end
  467. local function lbl(txt)
  468.     local i1=i("TextBox")
  469.     local i2=i("Frame")
  470.     insSet(i1,"Font",e.Font.SourceSans)
  471.     insSet(i1,"FontSize",e.FontSize.Size14)
  472.     insSet(i1,"Text",txt)
  473.     insSet(i1,"ClearTextOnFocus",false)
  474.     insSet(i1,"TextColor3",guiTheme.labelsTextColor)
  475.     insSet(i1,"Position",u2(0.5,0,0.5))
  476.     insSet(i1,"BackgroundTransparency",1)
  477.     insSet(i1,"Name",rs())
  478.     insSet(i1,"Parent",i2)
  479.     insSet(i2,"Size",u2(1,0,0,14))
  480.     insSet(i2,"BackgroundTransparency",1)
  481.     insSet(i2,"Name",rs())
  482.     insSet(i2,"Parent",i4)
  483.     return i1
  484. end
  485.  
  486. Draggable(i1)
  487.  
  488. lbl("by MyWorld")
  489. lbl("discord.gg/QMy5f6DrbH")
  490. lbl("original IL by LuaQuack")
  491.  
  492. local allowshiftlock=nil
  493. local ctrltp=nil
  494. local placeholders=nil
  495. local clickfling=nil
  496. local highlightflingtargets=nil
  497. local discharscripts=nil
  498. local flingchangestate=nil
  499. local respawntp=true
  500. local breakjointsmethod=nil
  501.  
  502. local c=nil
  503. local function stopreanimate()
  504.     if c then
  505.         c=nil
  506.         return true
  507.     end
  508.     return false
  509. end
  510. local function reanimate()
  511.     --[[
  512.         FDless reanimate by MyWorld
  513.         aka no client sided instances
  514.         "what else do i optimize here"
  515.     ]]
  516.  
  517.     local novoid = true --prevents parts from going under workspace.FallenPartsDestroyHeight if you control them
  518.     local speedlimit = 3000 --makes your parts move slower if the magnitude of their velocity is higher than this
  519.     local retVelTime = 0.51 --time that claimed parts have velocity to reclaim in case u lose them
  520.     local walkSpeed = 16 --your walkspeed (can be changed at runtime)
  521.     local jumpPower = 50 --your jump power (can be changed at runtime)
  522.     local gravity = 196.2 --how fast the characters velocity decreases while falling (can be changed at runtime)
  523.     local ctrlclicktp = ctrltp --makes you teleport where u point ur mouse cursor at when click and hold ctrl down
  524.     local clickfling = clickfling --makes you fling the person you clicked when its available to do so
  525.     local flingvel = v3(15000,16000,15000) --the rotation velocity that ur character will have while flinging
  526.  
  527.     if stopreanimate() then return end
  528.     c=insGet(lp,"Character")
  529.     if not (c and IsDescendantOf(c,ws)) then return end
  530.  
  531.     local rootpart=gp(c,"HumanoidRootPart","BasePart") or gp(c,"Torso","BasePart") or gp(c,"UpperTorso","BasePart") or timegp(c,"HumanoidRootPart","BasePart",0.5) or FindFirstChildWhichIsA(c,"BasePart")
  532.     if not rootpart then return end
  533.  
  534.     local cam=nil
  535.     --theres a way to have ws.currentcamera nil on heartbeat and still have the game run normally
  536.     local function refcam()
  537.         local newcam=insGet(ws,"CurrentCamera")
  538.         while not newcam do
  539.             Wait(GetPropertyChangedSignal(ws,"CurrentCamera"))
  540.             newcam=insGet(ws,"CurrentCamera")
  541.         end
  542.         cam=newcam
  543.     end
  544.     refcam()
  545.     local camcf=insGet(cam,"CFrame")
  546.     local enumCamS=e.CameraType.Scriptable
  547.     local camt=insGet(cam,"CameraType")
  548.     local camcon0=nil
  549.     local camcon1=nil
  550.     local camcon2=nil
  551.     local function onnewcamera()
  552.         refcam()
  553.         if camcon0 then
  554.             Disconnect(camcon0)
  555.             Disconnect(camcon1)
  556.             camcon0=nil
  557.         end
  558.         if not c then
  559.             if insGet(cam,"CameraType")==enumCamS then
  560.                 insSet(cam,"CameraType",camt)
  561.             end
  562.             return Disconnect(camcon2)
  563.         end
  564.         camcon0=Connect(GetPropertyChangedSignal(cam,"CFrame"),function()
  565.             if insGet(cam,"CFrame")~=camcf then
  566.                 insSet(cam,"CFrame",camcf)
  567.             end
  568.         end)
  569.         camcon1=Connect(GetPropertyChangedSignal(cam,"CameraType"),function()
  570.             if insGet(cam,"CameraType")~=enumCamS then
  571.                 insSet(cam,"CameraType",enumCamS)
  572.             end
  573.         end)
  574.         if insGet(cam,"CameraType")~=enumCamS then
  575.             insSet(cam,"CameraType",enumCamS)
  576.         end
  577.         if insGet(cam,"CFrame")~=camcf then
  578.             insSet(cam,"CFrame",camcf)
  579.         end
  580.     end
  581.     camcon2=Connect(GetPropertyChangedSignal(ws,"CurrentCamera"),onnewcamera)
  582.     onnewcamera()
  583.  
  584.     local rGravity=insGet(ws,"Gravity")
  585.     Connect(GetPropertyChangedSignal(ws,"Gravity"),function()
  586.         rGravity=insGet(ws,"Gravity")
  587.     end)
  588.  
  589.     local fpdh=insGet(ws,"FallenPartsDestroyHeight")
  590.     novoid=novoid and (fpdh+1)
  591.  
  592.     local Yvel=0
  593.     local cfr=insGet(rootpart,"CFrame")
  594.     local pos=cfGet(cfr,"Position")
  595.     local primarypart=nil
  596.     local shiftlock=false
  597.     local firstperson=false
  598.     local xzvel=v3_0
  599.     local v3_030=v3_010*3
  600.     local camcfLV=cfGet(camcf,"LookVector")
  601.     local camrot=cfl(v3_0,camcfLV)
  602.     local camcfRV=cfGet(camrot,"RightVector")
  603.     local cammag=-v3Get((cfGet(camcf,"Position")-(pos+v3_010*1.5)),"Magnitude")
  604.     pos=pos+v3_010*7
  605.     cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  606.  
  607.     local R6parts={
  608.         head={Name="Head"},
  609.         torso={Name="Torso"},
  610.         root={Name="HumanoidRootPart"},
  611.         leftArm={Name="Left Arm"},
  612.         rightArm={Name="Right Arm"},
  613.         leftLeg={Name="Left Leg"},
  614.         rightLeg={Name="Right Leg"}
  615.     }
  616.     rootpart=R6parts.root
  617.     local cframes={}
  618.     for i,v in next,R6parts do
  619.         cframes[v]=cfr
  620.     end
  621.     local joints={
  622.         {
  623.             Name="Neck",
  624.             Part0=R6parts.torso,Part1=R6parts.head,
  625.             C0=cf(0,2,0,-1,0,0,0,0,1,0,1,-0),
  626.             C1=cf(0,-1,0,-1,0,0,0,0,1,0,1,-0)
  627.         },
  628.         {
  629.             Name="RootJoint",
  630.             Part0=rootpart,Part1=R6parts.torso,
  631.             C0=cf(0,0,0,-1,0,0,0,0,1,0,1,-0),
  632.             C1=cf(0,0,0,-1,0,0,0,0,1,0,1,-0)
  633.         },
  634.         {
  635.             Name="Right Shoulder",
  636.             Part0=R6parts.torso,Part1=R6parts.rightArm,
  637.             C0=cf(2,1,0,0,0,1,0,1,-0,-1,0,0),
  638.             C1=cf(-1,1,0,0,0,1,0,1,-0,-1,0,0)
  639.         },
  640.         {
  641.             Name="Left Shoulder",
  642.             Part0=R6parts.torso,Part1=R6parts.leftArm,
  643.             C0=cf(-2,1,0,0,0,-1,0,1,0,1,0,0),
  644.             C1=cf(1,1,0,0,0,-1,0,1,0,1,0,0)
  645.         },
  646.         {
  647.             Name="Right Hip",
  648.             Part0=R6parts.torso,Part1=R6parts.rightLeg,
  649.             C0=cf(2,-2,0,0,0,1,0,1,-0,-1,0,0),
  650.             C1=cf(1,2,0,0,0,1,0,1,-0,-1,0,0)
  651.         },
  652.         {
  653.             Name="Left Hip",
  654.             Part0=R6parts.torso,Part1=R6parts.leftLeg,
  655.             C0=cf(-2,-2,0,0,0,-1,0,1,0,1,0,0),
  656.             C1=cf(-1,2,0,0,0,-1,0,1,0,1,0,0)
  657.         }
  658.     }
  659.  
  660.     local refreshedjoints={}
  661.     local refreshjointsI=nil
  662.     refreshjointsI=function(part)
  663.         tinsert(refreshedjoints,part)
  664.         for i,v in next,joints do
  665.             local part0=v.Part0
  666.             local part1=v.Part1
  667.             if part1 and (part0==part) then
  668.                 cframes[part1]=cfMul(cframes[part],cfMul(v.C0,Inverse(v.C1)))
  669.                 if not tfind(refreshedjoints,part1) then
  670.                     refreshjointsI(part1)
  671.                 end
  672.             elseif part0 and (part1==part) then
  673.                 cframes[part0]=cfMul(cframes[part],cfMul(v.C1,Inverse(v.C0)))
  674.                 if not tfind(refreshedjoints,part0) then
  675.                     refreshjointsI(part0)
  676.                 end
  677.             end
  678.         end
  679.     end
  680.     refreshjointsI(rootpart)
  681.     tclear(refreshedjoints)
  682.  
  683.     local attachments={
  684.         RightShoulderAttachment={R6parts.rightArm,cf(0,1,0,1,0,0,0,1,0,0,0,1)},
  685.         RightGripAttachment={R6parts.rightArm,cf(0,-1,0,1,0,0,0,1,0,0,0,1)},
  686.         LeftFootAttachment={R6parts.leftLeg,cf(0,-1,0,1,0,0,0,1,0,0,0,1)},
  687.         LeftShoulderAttachment={R6parts.leftArm,cf(0,1,0,1,0,0,0,1,0,0,0,1)},
  688.         LeftGripAttachment={R6parts.leftArm,cf(0,-1,0,1,0,0,0,1,0,0,0,1)},
  689.         RootAttachment={rootpart,cf(0,0,0,1,0,0,0,1,0,0,0,1)},
  690.         RightFootAttachment={R6parts.rightLeg,cf(0,-1,0,1,0,0,0,1,0,0,0,1)},
  691.         NeckAttachment={R6parts.torso,cf(0,1,0,1,0,0,0,1,0,0,0,1)},
  692.         BodyFrontAttachment={R6parts.torso,cf(0,0,-0.5,1,0,0,0,1,0,0,0,1)},
  693.         BodyBackAttachment={R6parts.torso,cf(0,0,0.5,1,0,0,0,1,0,0,0,1)},
  694.         LeftCollarAttachment={R6parts.torso,cf(-1,1,0,1,0,0,0,1,0,0,0,1)},
  695.         RightCollarAttachment={R6parts.torso,cf(1,1,0,1,0,0,0,1,0,0,0,1)},
  696.         WaistFrontAttachment={R6parts.torso,cf(0,-1,-0.5,1,0,0,0,1,0,0,0,1)},
  697.         WaistCenterAttachment={R6parts.torso,cf(0,-1,0,1,0,0,0,1,0,0,0,1)},
  698.         WaistBackAttachment={R6parts.torso,cf(0,-1,0.5,1,0,0,0,1,0,0,0,1)},
  699.         HairAttachment={R6parts.head,cf(0,0.6,0,1,0,0,0,1,0,0,0,1)},
  700.         HatAttachment={R6parts.head,cf(0,0.6,0,1,0,0,0,1,0,0,0,1)},
  701.         FaceFrontAttachment={R6parts.head,cf(0,0,-0.6,1,0,0,0,1,0,0,0,1)},
  702.         FaceCenterAttachment={R6parts.head,cf(0,0,0,1,0,0,0,1,0,0,0,1)}
  703.     }
  704.  
  705.     local function getPart(name,blacklist)
  706.         for i,v in next,cframes do
  707.             if (i.Name==name) and not (blacklist and tfind(blacklist,i)) then
  708.                 return i
  709.             end
  710.         end
  711.         return nil
  712.     end
  713.  
  714.     local function getJoint(name)
  715.         for i,v in next,joints do
  716.             if v.Name==name then
  717.                 return v
  718.             end
  719.         end
  720.         return {C0=cf_0,C1=cf_0}
  721.     end
  722.  
  723.     local function getPartFromMesh(m,t,blacklist)
  724.         if blacklist then
  725.             for v,_ in next,cframes do
  726.                 if v.m and (not tfind(blacklist,v)) and sfind(v.m,m) and sfind(v.t,t) then
  727.                     return v
  728.                 end
  729.             end
  730.         else
  731.             for v,_ in next,cframes do
  732.                 if v.m and sfind(v.m,m) and sfind(v.t,t) then
  733.                     return v
  734.                 end
  735.             end
  736.         end
  737.         local p={m=m,t=t}
  738.         cframes[p]=cfr
  739.         local j={C0=cf_0,C1=cf_0,Part0=p}
  740.         p.j=j
  741.         return p
  742.     end
  743.  
  744.     local function getPartJoint(p)
  745.         if cframes[p] then
  746.             local j=p.j
  747.             if j then
  748.                 return j
  749.             end
  750.             for i,v in next,joints do
  751.                 if v.Part0==p then
  752.                     return v
  753.                 end
  754.             end
  755.             for i,v in next,joints do
  756.                 if v.Part1==p then
  757.                     return v
  758.                 end
  759.             end
  760.         end
  761.         return nil
  762.     end
  763.  
  764.     local function getAccWeldFromMesh(m,t)
  765.         return getPartJoint(getPartFromMesh(m,t))
  766.     end
  767.  
  768.     local raycastparams=rp()
  769.     raycastparams.FilterType=e.RaycastFilterType.Blacklist
  770.     raycastparams.RespectCanCollide=true
  771.     local rayfilter={}
  772.     local characters={}
  773.     local function refreshrayfilter()
  774.         tclear(rayfilter)
  775.         for i,v in next,characters do
  776.             tinsert(rayfilter,v)
  777.         end
  778.         raycastparams.FilterDescendantsInstances=rayfilter
  779.     end
  780.     local flingtable={}
  781.     local rootparts={}
  782.     for i,v in next,accessorylimbs do
  783.         v.p=getPart(v.Name)
  784.     end
  785.     local function makePartCons(p,t)
  786.         if (t.p==p) and insGet(p,"Anchored") then
  787.             t.p=nil
  788.         end
  789.         local con0=Connect(GetPropertyChangedSignal(p,"Anchored"),function()
  790.             if insGet(p,"Anchored") then
  791.                 if t.p==p then
  792.                     t.c=nil
  793.                     t.p=nil
  794.                 end
  795.             elseif not t.p then
  796.                 t.p=p
  797.             end
  798.         end)
  799.         local con1=nil
  800.         con1=Connect(insGet(p,"AncestryChanged"),function()
  801.             if not IsDescendantOf(p,ws) then
  802.                 Disconnect(con0)
  803.                 Disconnect(con1)
  804.                 if t.p==p then
  805.                     t.p=nil
  806.                 end
  807.             end
  808.         end)
  809.     end
  810.     local ondes=nil
  811.     ondes=function(v)
  812.         if c and IsA(v,"Attachment") and IsDescendantOf(c,ws) then
  813.             local v1=attachments[insGet(v,"Name")]
  814.             if v1 then
  815.                 local p=insGet(v,"Parent")
  816.                 if insGet(p,"Parent")~=c then
  817.                     local meshid,textureid=getMeshOfPart(p)
  818.                     if meshid then
  819.                         local found=false
  820.                         for i,_ in next,cframes do
  821.                             if (meshid==i.m) and (textureid==i.t) then
  822.                                 local p1=i.p
  823.                                 if p1 and IsDescendantOf(p1,c) then
  824.                                     if p1==p then
  825.                                         found=true
  826.                                         break
  827.                                     end
  828.                                 else
  829.                                     found=true
  830.                                     i.p=p
  831.                                     makePartCons(p,i)
  832.                                     break
  833.                                 end
  834.                             else
  835.                                 local j=i.j
  836.                                 if j and sfind(meshid,i.m) and sfind(textureid,i.t) then
  837.                                     i.m=meshid
  838.                                     i.t=textureid
  839.                                     i.l=insGet(p,"Position")
  840.                                     i.p=p
  841.                                     makePartCons(p,i)
  842.                                     i.j=nil
  843.                                     i.Name=insGet(p,"Name")
  844.                                     j.C0=insGet(v,"CFrame")
  845.                                     j.C1=v1[2]
  846.                                     j.Part1=v1[1]
  847.                                     tinsert(joints,j)
  848.                                     found=true
  849.                                     break
  850.                                 end
  851.                             end
  852.                         end
  853.                         if not found then
  854.                             for i,l in next,accessorylimbs do
  855.                                 if l.p and sfind(meshid,l.meshid) and sfind(textureid,l.textureid) then
  856.                                     local t={Name=insGet(p,"Name"),l=insGet(p,"Position"),m=meshid,t=textureid,p=p}
  857.                                     makePartCons(p,t)
  858.                                     if placeholders then
  859.                                         t.v=makeplaceholder(p)
  860.                                     end
  861.                                     cframes[t]=insGet(p,"CFrame")
  862.                                     tinsert(joints,{Part0=t,Part1=l.p,C0=l.C0,C1=cf_0})
  863.                                     l.p=nil
  864.                                     found=true
  865.                                     break
  866.                                 end
  867.                             end
  868.                             if not found then
  869.                                 local t={Name=insGet(p,"Name"),l=insGet(p,"Position"),m=meshid,t=textureid,p=p}
  870.                                 makePartCons(p,t)
  871.                                 if placeholders then
  872.                                     t.v=makeplaceholder(p)
  873.                                 end
  874.                                 cframes[t]=insGet(p,"CFrame")
  875.                                 tinsert(joints,{Part0=t,Part1=v1[1],C0=insGet(v,"CFrame"),C1=v1[2]})
  876.                             end
  877.                         end
  878.                     end
  879.                 end
  880.             end
  881.         end
  882.     end
  883.  
  884.     local charcons={}
  885.     local function onplayer(v)
  886.         local lastc=nil
  887.         local function oncharacter()
  888.             local newc=insGet(v,"Character")
  889.             if c and newc and (newc~=lastc) then
  890.                 lastc=newc
  891.                 characters[v]=newc
  892.                 refreshrayfilter()
  893.                 if v==lp then
  894.                     if discharscripts then
  895.                         Connect(insGet(newc,"DescendantAdded"),discharscripts)
  896.                         for i,v in next,GetDescendants(newc) do
  897.                             if IsA(v,"Script") then
  898.                                 insSet(v,"Disabled",true)
  899.                             end
  900.                         end
  901.                     end
  902.                     local hrp=timegp(newc,"HumanoidRootPart","BasePart",10)
  903.                     if not (hrp and c and IsDescendantOf(newc,ws)) then return end
  904.                     c=newc
  905.                     local fi,fv=next(flingtable)
  906.                     if fi then
  907.                         if flingchangestate then
  908.                             local hum=FindFirstChildOfClass(c,"Humanoid")
  909.                             if hum then
  910.                                 insGet(hum,"ChangeState")(hum,e.HumanoidStateType.Physics)
  911.                             end
  912.                         end
  913.                         for i,v in next,tclone(flingtable) do
  914.                             if not c then
  915.                                 return
  916.                             end
  917.                             local startpos=insGet(i,"Position")
  918.                             local stoptime=sine+3
  919.                             while true do
  920.                                 twait()
  921.                                 if sine>stoptime then
  922.                                     break
  923.                                 end
  924.                                 if insGet(i,"Anchored") or not IsDescendantOf(i,ws) then
  925.                                     break
  926.                                 end
  927.                                 if v3Get((startpos-insGet(i,"Position")),"Magnitude")>200 then
  928.                                     break
  929.                                 end
  930.                                 local tcf=cfAdd(insGet(i,"CFrame"),insGet(i,"AssemblyLinearVelocity")*(sin(sine*15)+1))
  931.                                 if novoid and (cfGet(tcf,"Y")<novoid) then
  932.                                     tcf=cfAdd(tcf,v3_010*(novoid-cfGet(tcf,"Y")))
  933.                                 end
  934.                                 insSet(hrp,"CFrame",tcf)
  935.                                 insSet(hrp,"AssemblyLinearVelocity",insGet(i,"AssemblyLinearVelocity")*v3_101*75)
  936.                                 insSet(hrp,"AssemblyAngularVelocity",flingvel)
  937.                             end
  938.                             if v then
  939.                                 Destroy(v)
  940.                             end
  941.                             flingtable[i]=nil
  942.                         end
  943.                         insSet(hrp,"AssemblyLinearVelocity",v3_0)
  944.                         insSet(hrp,"AssemblyAngularVelocity",v3_0)
  945.                         insSet(hrp,"CFrame",cfr)
  946.                         twait(0.2501)
  947.                     end
  948.                     if respawntp then
  949.                         local startpos=pos+v3(mrandom(-32,32),0,mrandom(-32,32))
  950.                         local dir=nil
  951.                         local poscheck=true
  952.                         while poscheck do
  953.                             poscheck=false
  954.                             for i,v in next,rootparts do
  955.                                 local diff=(startpos-insGet(v,"Position"))*v3_101
  956.                                 if v3Get(diff,"Magnitude")<10 then
  957.                                     poscheck=true
  958.                                     dir=dir or (v3Get(diff,"Unit") * 3)
  959.                                     startpos=startpos+dir
  960.                                 end
  961.                             end
  962.                             local diff=(startpos-pos)*v3_101
  963.                             if v3Get(diff,"Magnitude")<10 then
  964.                                 poscheck=true
  965.                                 dir=dir or (v3Get(diff,"Unit") * 3)
  966.                                 startpos=startpos+dir
  967.                             end
  968.                         end
  969.                         startpos=cfAdd(cfGet(cfr,"Rotation"),startpos)
  970.                         insSet(hrp,"CFrame",startpos)
  971.                         insSet(hrp,"AssemblyLinearVelocity",v3_0)
  972.                         insSet(hrp,"AssemblyAngularVelocity",v3_0)
  973.                         twait(0.2501)
  974.                     end
  975.                     if newc~=c then
  976.                         return
  977.                     end
  978.                     primarypart=insGet(newc,"PrimaryPart") or hrp
  979.                     if breakjointsmethod==1 then
  980.                         insGet(newc,"BreakJoints")(newc)
  981.                         local h=FindFirstChildOfClass(newc,"Humanoid")
  982.                         if h then
  983.                             insSet(h,"Health",0)
  984.                         end
  985.                     elseif breakjointsmethod==2 then
  986.                         local h=FindFirstChildOfClass(newc,"Humanoid")
  987.                         if h then
  988.                             insSet(h,"Health",0)
  989.                         else
  990.                             insGet(newc,"BreakJoints")(newc)
  991.                         end
  992.                     else
  993.                         insGet(newc,"BreakJoints")(newc)
  994.                     end
  995.                     Connect(insGet(newc,"DescendantAdded"),ondes)
  996.                     for i,v in next,GetDescendants(newc) do
  997.                         ondes(v)
  998.                     end
  999.                 else
  1000.                     local hrp=timegp(newc,"HumanoidRootPart","BasePart",10)
  1001.                     if hrp and c and IsDescendantOf(newc,ws) then
  1002.                         rootparts[v]=hrp
  1003.                     end
  1004.                 end
  1005.             end
  1006.         end
  1007.         charcons[v]=Connect(GetPropertyChangedSignal(v,"Character"),oncharacter)
  1008.         oncharacter()
  1009.     end
  1010.     for i,v in next,GetPlayers(plrs) do if v~=lp then tspawn(onplayer,v) end end
  1011.     Connect(insGet(plrs,"PlayerAdded"),onplayer)
  1012.     onplayer(lp)
  1013.     Connect(insGet(plrs,"PlayerRemoving"),function(v)
  1014.         local charcon=charcons[v]
  1015.         if charcon then
  1016.             Disconnect(charcon)
  1017.         end
  1018.         characters[v]=nil
  1019.         rootparts[v]=nil
  1020.     end)
  1021.  
  1022.     local mradN05=rad(-0.5)
  1023.     local KeyCode=e.KeyCode
  1024.     local enumMLC=e.MouseBehavior.LockCenter
  1025.     local enumMB2=e.UserInputType.MouseButton2
  1026.     local enumMLCP=e.MouseBehavior.LockCurrentPosition
  1027.     local enumMD=e.MouseBehavior.Default
  1028.     local enumMW=e.UserInputType.MouseWheel
  1029.     local enumMM=e.UserInputType.MouseMovement
  1030.  
  1031.     local mouseBehavior=nil
  1032.     local lastMouseBehavior=insGet(uis,"MouseBehavior")
  1033.     Connect(GetPropertyChangedSignal(uis,"MouseBehavior"),function()
  1034.         if mouseBehavior and (insGet(uis,"MouseBehavior")~=mouseBehavior) then
  1035.             insSet(uis,"MouseBehavior",mouseBehavior)
  1036.         end
  1037.     end)
  1038.  
  1039.     local mode="default"
  1040.     local defaultmode={}
  1041.     local modes={default=defaultmode}
  1042.  
  1043.     local lerpsIdle=emptyfunction
  1044.     local lerpsWalk=emptyfunction
  1045.     local lerpsJump=emptyfunction
  1046.     local lerpsFall=emptyfunction
  1047.  
  1048.     local function addmode(key,mode)
  1049.         if (type(key)~="string") or (type(mode)~="table") then
  1050.             return
  1051.         end
  1052.         for i,v in next,mode do
  1053.             if type(v)~="function" then
  1054.                 mode[i]=nil
  1055.             end
  1056.         end
  1057.         if key=="default" then
  1058.             defaultmode=mode
  1059.             modes.default=mode
  1060.             lerpsIdle=mode.idle or emptyfunction
  1061.             lerpsWalk=mode.walk or emptyfunction
  1062.             lerpsJump=mode.jump or emptyfunction
  1063.             lerpsFall=mode.fall or emptyfunction
  1064.             if mode.modeEntered then
  1065.                 mode.modeEntered()
  1066.             end
  1067.         elseif #key==1 then
  1068.             key=KeyCode[supper(ssub(key,1,1))]
  1069.             modes[key]=mode
  1070.         end
  1071.     end
  1072.  
  1073.     local keyW=KeyCode.W
  1074.     local Wpressed=IsKeyDown(uis,keyW)
  1075.     local keyA=KeyCode.A
  1076.     local Apressed=IsKeyDown(uis,keyA)
  1077.     local keyS=KeyCode.S
  1078.     local Spressed=IsKeyDown(uis,keyS)
  1079.     local keyD=KeyCode.D
  1080.     local Dpressed=IsKeyDown(uis,keyD)
  1081.     local keySpace=KeyCode.Space
  1082.     local jumpingInput=IsKeyDown(uis,keySpace)
  1083.  
  1084.     local FWmovement=0
  1085.     local RTmovement=0
  1086.     local isWalking=false
  1087.     local function refreshKeyboardMovement()
  1088.         if Wpressed then if Spressed then if Dpressed then if Apressed then isWalking=false else FWmovement=0 RTmovement=1 isWalking=true end else if Apressed then FWmovement=0 RTmovement=-1 isWalking=true else isWalking=false end end else FWmovement=1 if Dpressed then if Apressed then RTmovement=0 else RTmovement=1 end else if Apressed then RTmovement=-1 else RTmovement=0 end end isWalking=true end else if Spressed then FWmovement=-1 if Dpressed then if Apressed then RTmovement=0 else RTmovement=1 end else if Apressed then RTmovement=-1 else RTmovement=0 end end isWalking=true else if Dpressed then if Apressed then isWalking=false else FWmovement=0 RTmovement=1 isWalking=true end else if Apressed then FWmovement=0 RTmovement=-1 isWalking=true else isWalking=false end end end end
  1089.     end
  1090.     refreshKeyboardMovement()
  1091.  
  1092.     local keyShift=KeyCode.LeftShift
  1093.     Connect(insGet(uis,"InputBegan"),function(a)
  1094.         if insGet(gs,"MenuIsOpen") or GetFocusedTextBox(uis) then
  1095.             return
  1096.         end
  1097.         a=insGet(a,"KeyCode")
  1098.         if a==keyW then
  1099.             Wpressed=true
  1100.             refreshKeyboardMovement()
  1101.         elseif a==keyA then
  1102.             Apressed=true
  1103.             refreshKeyboardMovement()
  1104.         elseif a==keyS then
  1105.             Spressed=true
  1106.             refreshKeyboardMovement()
  1107.         elseif a==keyD then
  1108.             Dpressed=true
  1109.             refreshKeyboardMovement()
  1110.         elseif a==keySpace then
  1111.             jumpingInput=true
  1112.         elseif a==keyShift then
  1113.             shiftlock=allowshiftlock and not shiftlock
  1114.         elseif modes[a] then
  1115.             if modes[mode].modeLeft then
  1116.                 modes[mode].modeLeft()
  1117.             end
  1118.             if mode==a then
  1119.                 mode="default"
  1120.             else
  1121.                 mode=a
  1122.             end
  1123.             local modet=modes[mode]
  1124.             lerpsIdle=modet.idle or defaultmode.idle or emptyfunction
  1125.             lerpsWalk=modet.walk or defaultmode.walk or emptyfunction
  1126.             lerpsJump=modet.jump or defaultmode.jump or emptyfunction
  1127.             lerpsFall=modet.fall or defaultmode.fall or emptyfunction
  1128.             if modes[mode].modeEntered then
  1129.                 modes[mode].modeEntered()
  1130.             end
  1131.         end
  1132.     end)
  1133.     Connect(insGet(uis,"InputEnded"),function(a)
  1134.         a=insGet(a,"KeyCode")
  1135.         if a==keyW then
  1136.             Wpressed=false
  1137.             refreshKeyboardMovement()
  1138.         elseif a==keyA then
  1139.             Apressed=false
  1140.             refreshKeyboardMovement()
  1141.         elseif a==keyS then
  1142.             Spressed=false
  1143.             refreshKeyboardMovement()
  1144.         elseif a==keyD then
  1145.             Dpressed=false
  1146.             refreshKeyboardMovement()
  1147.         elseif a==keySpace then
  1148.             jumpingInput=false
  1149.         end
  1150.     end)
  1151.  
  1152.     local thumbstickEndX=0
  1153.     local thumbstickStartY=0
  1154.  
  1155.     local thumbstickSizeMultiplier=0
  1156.  
  1157.     local jumpStartX=0
  1158.     local jumpStartY=0
  1159.     local jumpEndX=0
  1160.     local jumpEndY=0
  1161.  
  1162.     local thumbstickInputObject=nil
  1163.     local jumpInputObject=nil
  1164.     local cameraRotateInputObject=nil
  1165.     local cameraZoomInputObject=nil
  1166.  
  1167.     local thumbstickTouchStart=v3_0
  1168.     local cameraZoomInputMagnitude=0
  1169.  
  1170.     Connect(insGet(uis,"TouchStarted"),function(inputObject)
  1171.         if insGet(gs,"MenuIsOpen") or GetFocusedTextBox(uis) then
  1172.             return
  1173.         end
  1174.  
  1175.         local touchPos=insGet(inputObject,"Position")
  1176.         local touchX=v3Get(touchPos,"X")
  1177.         local touchY=v3Get(touchPos,"Y")
  1178.  
  1179.         if (not thumbstickInputObject) and touchX<thumbstickEndX and touchY>thumbstickStartY then
  1180.             thumbstickInputObject=inputObject
  1181.             thumbstickTouchStart=insGet(inputObject,"Position")
  1182.             isWalking=false
  1183.         elseif (not jumpInputObject) and touchY>jumpStartY and touchX>jumpStartX and touchX<jumpEndX and touchY<jumpEndY then
  1184.             jumpInputObject=inputObject
  1185.             jumpingInput=true
  1186.         elseif not cameraRotateInputObject then
  1187.             cameraRotateInputObject=inputObject
  1188.         else
  1189.             cameraZoomInputObject=inputObject
  1190.             cameraZoomInputMagnitude=v3Get(insGet(cameraRotateInputObject,"Position")-insGet(cameraZoomInputObject,"Position"),"Magnitude")
  1191.         end
  1192.     end)
  1193.     Connect(insGet(uis,"TouchMoved"),function(inputObject)
  1194.         local touchPos=insGet(inputObject,"Position")
  1195.         local touchX=v3Get(touchPos,"X")
  1196.         local touchY=v3Get(touchPos,"Y")
  1197.         if inputObject==thumbstickInputObject then
  1198.             local direction=insGet(inputObject,"Position")-thumbstickTouchStart
  1199.             local directionMag=v3Get(direction,"Magnitude")/thumbstickSizeMultiplier
  1200.             if directionMag>0.05 then
  1201.                 isWalking=true
  1202.                 direction=v3Get(direction,"Unit")*min(1,(directionMag-0.05)/0.95)
  1203.                 FWmovement=-v3Get(direction,"Y")
  1204.                 RTmovement=v3Get(direction,"X")
  1205.             else
  1206.                 isWalking=false
  1207.             end
  1208.         elseif inputObject==jumpInputObject then
  1209.             jumpingInput=touchY>jumpStartY and touchX>jumpStartX and touchX<jumpEndX and touchY<jumpEndY
  1210.         else
  1211.             if cameraZoomInputObject then
  1212.                 local newMagnitude=v3Get(insGet(cameraRotateInputObject,"Position")-insGet(cameraZoomInputObject,"Position"),"Magnitude")                  
  1213.                 cammag=cammag+(newMagnitude-cameraZoomInputMagnitude)*0.04*(0.75-cammag/4)
  1214.                 cameraZoomInputMagnitude=newMagnitude
  1215.                 if cammag<0 then
  1216.                     firstperson=false
  1217.                 else
  1218.                     cammag=0
  1219.                     firstperson=true
  1220.                 end
  1221.             elseif inputObject==cameraRotateInputObject then
  1222.                 local rotation=GetMouseDelta(uis)*mradN05
  1223.                 camcfLV=cfGet(cfMul(camrot,angles(rotation.Y,rotation.X,0)),"LookVector")
  1224.                 camrot=cfl(v3_0,camcfLV)
  1225.                 camcfRV=cfGet(camrot,"RightVector")
  1226.             end
  1227.         end
  1228.     end)
  1229.     Connect(insGet(uis,"TouchEnded"),function(inputObject)
  1230.         if inputObject==thumbstickInputObject then
  1231.             thumbstickInputObject=nil
  1232.             isWalking=false
  1233.         elseif inputObject==jumpInputObject then
  1234.             jumpInputObject=nil
  1235.             jumpingInput=false
  1236.         elseif inputObject==cameraRotateInputObject then
  1237.             cameraRotateInputObject=nil
  1238.             cameraZoomInputObject=nil
  1239.         elseif inputObject==cameraZoomInputObject then
  1240.             cameraZoomInputObject=nil
  1241.         end
  1242.     end)
  1243.  
  1244.     local function refreshTouchRegions()
  1245.         local sX=insGet(mouse,"ViewSizeX")
  1246.         local sY=insGet(mouse,"ViewSizeY")
  1247.         local isSmallScreen=min(sX,sY)<=500
  1248.  
  1249.         sY=sY+insGet(gs,"TopbarInset").Height
  1250.  
  1251.         thumbstickEndX=sX*0.4
  1252.         thumbstickStartY=(sY+0)*0.333
  1253.  
  1254.         if isSmallScreen then
  1255.             thumbstickSizeMultiplier=35
  1256.             jumpStartX=sX-95
  1257.             jumpStartY=sY-90
  1258.             jumpEndX=jumpStartX+70
  1259.             jumpEndY=jumpStartY+70
  1260.         else
  1261.             thumbstickSizeMultiplier=60
  1262.             jumpStartX=sX-170
  1263.             jumpStartY=sY-210
  1264.             jumpEndX=jumpStartX+120
  1265.             jumpEndY=jumpStartY+120
  1266.         end
  1267.     end
  1268.     Connect(GetPropertyChangedSignal(mouse,"ViewSizeX"),refreshTouchRegions)
  1269.     Connect(GetPropertyChangedSignal(mouse,"ViewSizeY"),refreshTouchRegions)
  1270.     Connect(GetPropertyChangedSignal(gs,"TopbarInset"),refreshTouchRegions)
  1271.     refreshTouchRegions()
  1272.  
  1273.     local mouseCameraMove=false
  1274.     Connect(insGet(uis,"InputChanged"),function(a,b)
  1275.         if b then return end
  1276.         local inputType=insGet(a,"UserInputType")
  1277.         if mouseCameraMove and inputType==enumMM then
  1278.             local rotation=GetMouseDelta(uis)*mradN05
  1279.             camcfLV=cfGet(cfMul(camrot,angles(rotation.Y,rotation.X,0)),"LookVector")
  1280.             camrot=cfl(v3_0,camcfLV)
  1281.             camcfRV=cfGet(camrot,"RightVector")
  1282.         elseif inputType==enumMW then
  1283.             cammag=cammag+v3Get(insGet(a,"Position"),"Z")*(0.75-cammag/4)
  1284.             if cammag<0 then
  1285.                 firstperson=false
  1286.             else
  1287.                 cammag=0
  1288.                 firstperson=true
  1289.             end
  1290.         end
  1291.     end)
  1292.  
  1293.     local function predictionfling(target)
  1294.         if not c then
  1295.             return false
  1296.         end
  1297.         if typeof(target)~="Instance" then
  1298.             target=insGet(mouse,"Target")
  1299.             if not target then
  1300.                 return false
  1301.             end
  1302.         end
  1303.         if not IsDescendantOf(target,ws) then
  1304.             return false
  1305.         end
  1306.         if IsA(target,"Humanoid") or IsA(target,"BasePart") then
  1307.             target=insGet(target,"Parent")
  1308.             if IsA(target,"Accessory") then
  1309.                 target=insGet(target,"Parent")
  1310.             end
  1311.         end
  1312.         if (target==c) or (not IsA(target,"Model")) then
  1313.             return false
  1314.         end
  1315.         local targetpart=gp(target,"HumanoidRootPart","BasePart") or gp(target,"Torso","BasePart") or gp(target,"UpperTorso","BasePart")
  1316.         if (not targetpart) or (flingtable[targetpart]~=nil) then
  1317.             return false
  1318.         end
  1319.         if highlightflingtargets then
  1320.             local h=i("Highlight")
  1321.             insSet(h,"Name",rs())
  1322.             insSet(h,"Adornee",target)
  1323.             insSet(h,"FillColor",c3(1,0,0))
  1324.             insSet(h,"OutlineColor",c3(1,0,0))
  1325.             insSet(h,"FillTransparency",0.5)
  1326.             insSet(h,"OutlineTransparency",0)
  1327.             insSet(h,"Parent",i10)
  1328.             flingtable[targetpart]=h
  1329.         else
  1330.             flingtable[targetpart]=false
  1331.         end
  1332.         return true
  1333.     end
  1334.  
  1335.     local clickConnection=nil
  1336.     if ctrlclicktp then
  1337.         ctrlclicktp=KeyCode.LeftControl
  1338.         local tpoff=v3_010*10
  1339.         if clickfling then
  1340.             clickConnection=Connect(insGet(mouse,"Button1Down"),function()
  1341.                 if insGet(mouse,"Target") then
  1342.                     if IsKeyDown(uis,ctrlclicktp) then
  1343.                         pos=cfGet(insGet(mouse,"Hit"),"Position")+tpoff
  1344.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1345.                         xzvel=v3_0
  1346.                         Yvel=0
  1347.                     else
  1348.                         predictionfling()
  1349.                     end
  1350.                 end
  1351.             end)
  1352.         else
  1353.             clickConnection=Connect(insGet(mouse,"Button1Down"),function()
  1354.                 if insGet(mouse,"Target") and IsKeyDown(uis,ctrlclicktp) then
  1355.                     pos=cfGet(insGet(mouse,"Hit"),"Position")+tpoff
  1356.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1357.                     xzvel=v3_0
  1358.                     Yvel=0
  1359.                 end
  1360.             end)
  1361.         end
  1362.     elseif clickfling then
  1363.         clickConnection=Connect(insGet(mouse,"Button1Down"),predictionfling)
  1364.     end
  1365.  
  1366.     local noYvelTime=1
  1367.     local lastsine=sine
  1368.     local con=nil
  1369.     local function mainFunction()
  1370.         if not c then
  1371.             for i,v in next,cframes do
  1372.                 local p=i.v
  1373.                 if p then
  1374.                     Destroy(p)
  1375.                 end
  1376.             end
  1377.             for i,v in next,flingtable do
  1378.                 if v then --it could be false
  1379.                     Destroy(v)
  1380.                 end
  1381.             end
  1382.             for i,v in next,charcons do
  1383.                 Disconnect(v)
  1384.             end
  1385.             if clickConnection then
  1386.                 Disconnect(clickConnection)
  1387.             end
  1388.             mouseBehavior=nil
  1389.             insSet(uis,"MouseBehavior",enumMD)
  1390.             onnewcamera()
  1391.             local c=insGet(lp,"Character")
  1392.             if c then
  1393.                 insSet(cam,"CameraSubject",FindFirstChildOfClass(c,"Humanoid"))
  1394.             end
  1395.             return con and Disconnect(con)
  1396.         end
  1397.  
  1398.         sine=osclock()
  1399.         local delta=sine-lastsine
  1400.         deltaTime=min(delta*10,1)
  1401.         lastsine=sine
  1402.  
  1403.         if shiftlock then
  1404.             if allowshiftlock then
  1405.                 mouseBehavior=enumMLC
  1406.                 mouseCameraMove=true
  1407.             else
  1408.                 shiftlock=false
  1409.             end
  1410.         elseif firstperson then
  1411.             mouseBehavior=enumMLC
  1412.             mouseCameraMove=true
  1413.         elseif IsMouseButtonPressed(uis,enumMB2) then
  1414.             mouseBehavior=enumMLCP
  1415.             mouseCameraMove=true
  1416.         else
  1417.             mouseBehavior=enumMD
  1418.             mouseCameraMove=false
  1419.         end
  1420.         if lastMouseBehavior~=mouseBehavior then
  1421.             lastMouseBehavior=mouseBehavior
  1422.             insSet(uis,"MouseBehavior",mouseBehavior)
  1423.         end
  1424.  
  1425.         local raycastresult=Raycast(ws,pos,v3_010*(fpdh-v3Get(pos,"Y")),raycastparams)
  1426.         local onground=nil
  1427.         if raycastresult then
  1428.             raycastresult=v3Get(raycastresult.Position,"Y")
  1429.             onground=v3Get(pos,"Y")-raycastresult<10.01
  1430.             if onground then
  1431.                 Yvel=0
  1432.                 pos=pos+v3_010*(raycastresult+10-v3Get(pos,"Y"))*min(delta*20,1)
  1433.                 if jumpingInput and (jumpPower>0) then
  1434.                     Yvel=jumpPower
  1435.                     onground=false
  1436.                 end
  1437.             else
  1438.                 Yvel=Yvel-gravity*delta
  1439.                 if v3Get(pos,"Y")+Yvel*delta<raycastresult then
  1440.                     Yvel=0
  1441.                     pos=pos+v3_010*(raycastresult+10-v3Get(pos,"Y"))
  1442.                 end
  1443.             end
  1444.         else
  1445.             Yvel=0
  1446.             onground=false
  1447.         end
  1448.  
  1449.         if firstperson then
  1450.             if isWalking then
  1451.                 if walkSpeed==0 then
  1452.                     xzvel=v3_0
  1453.                     if onground then
  1454.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1455.                         camcf=cfAdd(camrot,pos+v3_030)
  1456.                         cframes[rootpart]=cfr
  1457.                         insSet(cam,"CFrame",camcf)
  1458.                         lerpsIdle()
  1459.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1460.                         xzvel=xzvel*(1-noYvelTime)
  1461.                     elseif Yvel>0 then
  1462.                         pos=pos+v3_010*Yvel*delta
  1463.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1464.                         camcf=cfAdd(camrot,pos+v3_030)
  1465.                         cframes[rootpart]=cfr
  1466.                         insSet(cam,"CFrame",camcf)
  1467.                         lerpsJump()
  1468.                         noYvelTime=0
  1469.                     else
  1470.                         pos=pos+v3_010*Yvel*delta
  1471.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1472.                         camcf=cfAdd(camrot,pos+v3_030)
  1473.                         cframes[rootpart]=cfr
  1474.                         insSet(cam,"CFrame",camcf)
  1475.                         lerpsFall()
  1476.                         noYvelTime=0
  1477.                     end
  1478.                 else
  1479.                     xzvel=v3Get(v3Get(camcfLV*v3_101,"Unit")*FWmovement+v3Get(camcfRV*v3_101,"Unit")*RTmovement,"Unit")*walkSpeed
  1480.                     if onground then
  1481.                         pos=pos+xzvel*delta
  1482.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1483.                         camcf=cfAdd(camrot,pos+v3_030)
  1484.                         cframes[rootpart]=cfr
  1485.                         insSet(cam,"CFrame",camcf)
  1486.                         lerpsWalk()
  1487.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1488.                         xzvel=xzvel*(1-noYvelTime)
  1489.                     elseif Yvel>0 then
  1490.                         pos=pos+(xzvel+v3_010*Yvel)*delta
  1491.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1492.                         camcf=cfAdd(camrot,pos+v3_030)
  1493.                         cframes[rootpart]=cfr
  1494.                         insSet(cam,"CFrame",camcf)
  1495.                         lerpsJump()
  1496.                         noYvelTime=0
  1497.                     else
  1498.                         pos=pos+(xzvel+v3_010*Yvel)*delta
  1499.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1500.                         camcf=cfAdd(camrot,pos+v3_030)
  1501.                         cframes[rootpart]=cfr
  1502.                         insSet(cam,"CFrame",camcf)
  1503.                         lerpsFall()
  1504.                         noYvelTime=0
  1505.                     end
  1506.                 end
  1507.             else
  1508.                 xzvel=v3_0
  1509.                 if onground then
  1510.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1511.                     camcf=cfAdd(camrot,pos+v3_030)
  1512.                     cframes[rootpart]=cfr
  1513.                     insSet(cam,"CFrame",camcf)
  1514.                     lerpsIdle()
  1515.                     noYvelTime=min(noYvelTime+delta*0.3,1)
  1516.                     xzvel=xzvel*(1-noYvelTime)
  1517.                 elseif Yvel>0 then
  1518.                     pos=pos+v3_010*Yvel*delta
  1519.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1520.                     camcf=cfAdd(camrot,pos+v3_030)
  1521.                     cframes[rootpart]=cfr
  1522.                     insSet(cam,"CFrame",camcf)
  1523.                     lerpsJump()
  1524.                     noYvelTime=0
  1525.                 else
  1526.                     pos=pos+v3_010*Yvel*delta
  1527.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1528.                     camcf=cfAdd(camrot,pos+v3_030)
  1529.                     cframes[rootpart]=cfr
  1530.                     insSet(cam,"CFrame",camcf)
  1531.                     lerpsFall()
  1532.                     noYvelTime=0
  1533.                 end
  1534.             end
  1535.         elseif shiftlock then  
  1536.             if isWalking then
  1537.                 if walkSpeed==0 then
  1538.                     xzvel=v3_0
  1539.                     if onground then
  1540.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1541.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1542.                         cframes[rootpart]=cfr
  1543.                         insSet(cam,"CFrame",camcf)
  1544.                         lerpsIdle()
  1545.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1546.                         xzvel=xzvel*(1-noYvelTime)
  1547.                     elseif Yvel>0 then
  1548.                         pos=pos+v3_010*Yvel*delta
  1549.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1550.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1551.                         cframes[rootpart]=cfr
  1552.                         insSet(cam,"CFrame",camcf)
  1553.                         lerpsJump()
  1554.                         noYvelTime=0
  1555.                     else
  1556.                         pos=pos+v3_010*Yvel*delta
  1557.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1558.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1559.                         cframes[rootpart]=cfr
  1560.                         insSet(cam,"CFrame",camcf)
  1561.                         lerpsFall()
  1562.                         noYvelTime=0
  1563.                     end
  1564.                 else
  1565.                     xzvel=v3Get(v3Get(camcfLV*v3_101,"Unit")*FWmovement+v3Get(camcfRV*v3_101,"Unit")*RTmovement,"Unit")*walkSpeed
  1566.                     if onground then
  1567.                         pos=pos+xzvel*delta
  1568.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1569.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1570.                         cframes[rootpart]=cfr
  1571.                         insSet(cam,"CFrame",camcf)
  1572.                         lerpsWalk()
  1573.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1574.                         xzvel=xzvel*(1-noYvelTime)
  1575.                     elseif Yvel>0 then
  1576.                         pos=pos+(xzvel+v3_010*Yvel)*delta
  1577.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1578.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1579.                         cframes[rootpart]=cfr
  1580.                         insSet(cam,"CFrame",camcf)
  1581.                         lerpsJump()
  1582.                         noYvelTime=0
  1583.                     else
  1584.                         pos=pos+(xzvel+v3_010*Yvel)*delta
  1585.                         cfr=cfl(pos,pos+camcfLV*v3_101)
  1586.                         camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1587.                         cframes[rootpart]=cfr
  1588.                         insSet(cam,"CFrame",camcf)
  1589.                         lerpsFall()
  1590.                         noYvelTime=0
  1591.                     end
  1592.                 end
  1593.             else
  1594.                 xzvel=v3_0
  1595.                 if onground then
  1596.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1597.                     camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1598.                     cframes[rootpart]=cfr
  1599.                     insSet(cam,"CFrame",camcf)
  1600.                     lerpsIdle()
  1601.                     noYvelTime=min(noYvelTime+delta*0.3,1)
  1602.                     xzvel=xzvel*(1-noYvelTime)
  1603.                 elseif Yvel>0 then
  1604.                     pos=pos+v3_010*Yvel*delta
  1605.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1606.                     camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1607.                     cframes[rootpart]=cfr
  1608.                     insSet(cam,"CFrame",camcf)
  1609.                     lerpsJump()
  1610.                     noYvelTime=0
  1611.                 else
  1612.                     pos=pos+v3_010*Yvel*delta
  1613.                     cfr=cfl(pos,pos+camcfLV*v3_101)
  1614.                     camcf=cfAdd(camrot,pos+v3_030+camcfRV*1.75+camcfLV*cammag)
  1615.                     cframes[rootpart]=cfr
  1616.                     insSet(cam,"CFrame",camcf)
  1617.                     lerpsFall()
  1618.                     noYvelTime=0
  1619.                 end
  1620.             end
  1621.         else
  1622.             if isWalking then
  1623.                 if walkSpeed==0 then
  1624.                     xzvel=v3_0
  1625.                     if onground then
  1626.                         cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1627.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1628.                         cframes[rootpart]=cfr
  1629.                         insSet(cam,"CFrame",camcf)
  1630.                         lerpsIdle()
  1631.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1632.                         xzvel=xzvel*(1-noYvelTime)
  1633.                     elseif Yvel>0 then
  1634.                         pos=pos+v3_010*Yvel*delta
  1635.                         cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1636.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1637.                         cframes[rootpart]=cfr
  1638.                         insSet(cam,"CFrame",camcf)
  1639.                         lerpsJump()
  1640.                         noYvelTime=0
  1641.                     else
  1642.                         pos=pos+v3_010*Yvel*delta
  1643.                         cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1644.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1645.                         cframes[rootpart]=cfr
  1646.                         insSet(cam,"CFrame",camcf)
  1647.                         lerpsFall()
  1648.                         noYvelTime=0
  1649.                     end
  1650.                 else
  1651.                     xzvel=v3Get(v3Get(camcfLV*v3_101,"Unit")*FWmovement+v3Get(camcfRV*v3_101,"Unit")*RTmovement,"Unit")*walkSpeed
  1652.                     if onground then
  1653.                         pos=pos+xzvel*delta
  1654.                         cfr=cfAdd(Lerp(cfGet(cfr,"Rotation"),cfl(v3_0,xzvel),deltaTime),pos)
  1655.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1656.                         cframes[rootpart]=cfr
  1657.                         insSet(cam,"CFrame",camcf)
  1658.                         lerpsWalk()
  1659.                         noYvelTime=min(noYvelTime+delta*0.3,1)
  1660.                         xzvel=xzvel*(1-noYvelTime)
  1661.                     elseif Yvel>0 then
  1662.                         pos=pos+(xzvel+(v3_010*Yvel))*delta
  1663.                         cfr=cfAdd(Lerp(cfGet(cfr,"Rotation"),cfl(v3_0,xzvel),deltaTime),pos)
  1664.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1665.                         cframes[rootpart]=cfr
  1666.                         insSet(cam,"CFrame",camcf)
  1667.                         lerpsJump()
  1668.                         noYvelTime=0
  1669.                     else
  1670.                         pos=pos+(xzvel+(v3_010*Yvel))*delta
  1671.                         cfr=cfAdd(Lerp(cfGet(cfr,"Rotation"),cfl(v3_0,xzvel),deltaTime),pos)
  1672.                         camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1673.                         cframes[rootpart]=cfr
  1674.                         insSet(cam,"CFrame",camcf)
  1675.                         lerpsFall()
  1676.                         noYvelTime=0
  1677.                     end
  1678.                 end
  1679.             else
  1680.                 xzvel=v3_0
  1681.                 if onground then
  1682.                     cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1683.                     camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1684.                     cframes[rootpart]=cfr
  1685.                     insSet(cam,"CFrame",camcf)
  1686.                     lerpsIdle()
  1687.                     noYvelTime=min(noYvelTime+delta*0.3,1)
  1688.                     xzvel=xzvel*(1-noYvelTime)
  1689.                 elseif Yvel>0 then
  1690.                     pos=pos+v3_010*Yvel*delta
  1691.                     cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1692.                     camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1693.                     cframes[rootpart]=cfr
  1694.                     insSet(cam,"CFrame",camcf)
  1695.                     lerpsJump()
  1696.                     noYvelTime=0
  1697.                 else
  1698.                     pos=pos+v3_010*Yvel*delta
  1699.                     cfr=cfAdd(cfGet(cfr,"Rotation"),pos)
  1700.                     camcf=cfAdd(camrot,pos+v3_030+camcfLV*cammag)
  1701.                     cframes[rootpart]=cfr
  1702.                     insSet(cam,"CFrame",camcf)
  1703.                     lerpsFall()
  1704.                     noYvelTime=0
  1705.                 end
  1706.             end
  1707.         end
  1708.  
  1709.         refreshjointsI(rootpart)
  1710.         tclear(refreshedjoints)
  1711.  
  1712.         local idlerv=v3(sin((sine-0.0375)*16),sin(sine*16),sin((sine+0.075)*16))
  1713.         local idleoff=idlerv*0.001
  1714.  
  1715.         local claimpos=insGet(primarypart,"Position")
  1716.         local claimposY=v3Get(claimpos,"Y")
  1717.         for i,v in next,cframes do
  1718.             local part=i.p
  1719.             if part then
  1720.                 if insGet(part,"ReceiveAge")==0 then
  1721.                     local placeholder=i.v
  1722.                     if novoid and (cfGet(v,"Y")<novoid) then
  1723.                         v=cfAdd(v,v3_010*(novoid-cfGet(v,"Y")))
  1724.                     end
  1725.                     local lastpos=i.l
  1726.                     local vel=(cfGet(v,"Position")-lastpos)/delta
  1727.                     if v3Get(vel,"Magnitude")<0.15 then
  1728.                         if placeholder then
  1729.                             insSet(placeholder,"Parent",nil)
  1730.                         end
  1731.                         v=cfAdd(v,idleoff)
  1732.                     elseif v3Get(vel,"Magnitude")>speedlimit then
  1733.                         if placeholder then
  1734.                             insSet(placeholder,"CFrame",v)
  1735.                             insSet(placeholder,"Parent",ws)
  1736.                         end
  1737.                         vel=v3Get(vel,"Unit")*speedlimit
  1738.                         v=cfAdd(cfGet(v,"Rotation"),lastpos+vel*delta)
  1739.                     elseif placeholder then
  1740.                         insSet(placeholder,"Parent",nil)
  1741.                     end
  1742.                     i.l=cfGet(v,"Position")
  1743.                     local claimtime=i.c
  1744.                     if claimtime then
  1745.                         if sine-claimtime<retVelTime then
  1746.                             insSet(part,"AssemblyLinearVelocity",(claimpos-cfGet(v,"Position"))*v3_101/getFallingTime(cfGet(v,"Y"),claimposY,rGravity)+v3_net)
  1747.                         else
  1748.                             insSet(part,"AssemblyLinearVelocity",getNetlessVelocity(vel*noYvelTime+xzvel))
  1749.                         end
  1750.                     else
  1751.                         i.c=sine
  1752.                         insSet(part,"AssemblyLinearVelocity",getNetlessVelocity(vel*noYvelTime+xzvel))
  1753.                     end
  1754.                     insSet(part,"CFrame",v)
  1755.                     insSet(part,"AssemblyAngularVelocity",idlerv)
  1756.                 else
  1757.                     i.c=nil
  1758.                     i.l=insGet(part,"Position")
  1759.                     local placeholder=i.v
  1760.                     if placeholder then
  1761.                         insSet(placeholder,"CFrame",v)
  1762.                         insSet(placeholder,"Parent",ws)
  1763.                     end
  1764.                 end
  1765.             else
  1766.                 local placeholder=i.v
  1767.                 if placeholder then
  1768.                     insSet(placeholder,"CFrame",v)
  1769.                     insSet(placeholder,"Parent",ws)
  1770.                 end
  1771.             end
  1772.         end
  1773.     end
  1774.  
  1775.     sine=osclock()
  1776.     lastsine=sine
  1777.     con=Connect(heartbeat,mainFunction)
  1778.     mainFunction()
  1779.  
  1780.     local function refreshjoints(v) --use this on the main part if u have parts that
  1781.         refreshjointsI(v) --are connected with each other but arent connected to rootpart
  1782.         tclear(refreshedjoints)
  1783.     end
  1784.  
  1785.     local legcfR=cf(1,-1,0)
  1786.     local legcfL=cf(-1,-1,0)
  1787.     local raydir=v3_010*-2
  1788.     local function raycastlegs() --this returns 2 values: right leg raycast offset, left leg raycast offset
  1789.         local rY=Raycast(ws,cfGet(cfMul(cfr,legcfR),"Position"),raydir,raycastparams)
  1790.         local lY=Raycast(ws,cfGet(cfMul(cfr,legcfL),"Position"),raydir,raycastparams)
  1791.         return rY and (v3Get(rY.Position,"Y")-(v3Get(pos,"Y")-3)) or 0,lY and (v3Get(lY.Position,"Y")-(v3Get(pos,"Y")-3)) or 0
  1792.     end
  1793.  
  1794.     local function velbycfrvec() --this returns 2 values: forward/backwards movement (from -1 to 1), right/left movement (from -1 to 1)
  1795.         local fw=cfGet(cfr,"LookVector")*xzvel/walkSpeed
  1796.         local rt=cfGet(cfr,"RightVector")*xzvel/walkSpeed
  1797.         return v3Get(fw,"X")+v3Get(fw,"Z"),v3Get(rt,"X")+v3Get(rt,"Z")
  1798.     end
  1799.  
  1800.     local lastvel=v3_0
  1801.     local velchg1=v3_0
  1802.     local function velchgbycfrvec() --this returns 2 values: forward/backwards velocity change, right/left velocity change
  1803.         velchg1=velchg1+(lastvel-xzvel) --i recommend setting velchg1 to v3_0 when u start using this function or it will look worse
  1804.         lastvel=xzvel
  1805.         velchg1=velchg1-velchg1*(deltaTime/2)
  1806.         local fw=cfGet(cfr,"LookVector")*velchg1/32
  1807.         local rt=cfGet(cfr,"RightVector")*velchg1/32
  1808.         return v3Get(fw,"X")+v3Get(fw,"Z"),v3Get(rt,"X")+v3Get(rt,"Z")
  1809.     end
  1810.  
  1811.     local lastYvel=0
  1812.     local velYchg1=0
  1813.     local function velYchg() --this returns Y axis velocity change
  1814.         velYchg1=clamp(velYchg1+(lastYvel-Yvel),-50,50) --i recommend setting velYchg1 to 0 when u start using this function or it will look worse
  1815.         lastYvel=Yvel
  1816.         velYchg1=velYchg1-velYchg1*(deltaTime/2)
  1817.         return velYchg1
  1818.     end
  1819.  
  1820.     local function rotToMouse(alpha) --this rotates ur character towards your mouse hit position
  1821.         cfr=Lerp(cfr,cfl(pos,pos*v3_010+cfGet(insGet(mouse,"Hit"),"Position")*v3_101),alpha or deltaTime)
  1822.     end
  1823.  
  1824.     local function glitchJoint(joint,targetGlitchTime,delayFrom,delayTo,radiansFrom,radiansTo)
  1825.         if sine>targetGlitchTime then --local glitchtime=0 addMode("x",{idle=function() glitchtime=glitchJoint(joint,glitchtime,0.2,0.4,-0.1,0.1) end})
  1826.             radiansFrom=radiansFrom*100
  1827.             radiansTo=radiansTo*100
  1828.             joint.C0=cfMul(joint.C0,angles(mrandom(radiansFrom,radiansTo)/100,mrandom(radiansFrom,radiansTo)/100,mrandom(radiansFrom,radiansTo)/100))
  1829.             return sine+mrandom(delayFrom*100,delayTo*100)/100
  1830.         end
  1831.         return targetGlitchTime
  1832.     end
  1833.  
  1834.     local function setWalkSpeed(n)
  1835.         if type(n)~="number" then
  1836.             n=16
  1837.         end
  1838.         walkSpeed=n
  1839.     end
  1840.     local function setJumpPower(n)
  1841.         if type(n)~="number" then
  1842.             n=50
  1843.         end
  1844.         jumpPower=n
  1845.     end
  1846.     local function setGravity(n)
  1847.         if type(n)~="number" then
  1848.             n=196.2
  1849.         end
  1850.         gravity=n
  1851.     end
  1852.     local function setCfr(v) --sets character cframe
  1853.         if typeof(v)=="CFrame" then
  1854.             local newpos=cfGet(v,"Position")
  1855.             camcf=cfAdd(camcf,newpos-pos)
  1856.             insSet(cam,"CFrame",camcf)
  1857.             cfr=v
  1858.             pos=newpos
  1859.         elseif typeof(v)=="Vector3" then
  1860.             camcf=cfAdd(camcf,v-pos)
  1861.             insSet(cam,"CFrame",camcf)
  1862.             cfr=cfAdd(cfGet(cfr,"Rotation"),v)
  1863.             pos=v
  1864.         end
  1865.     end
  1866.     local function getVel() --returns character velocity
  1867.         return xzvel+v3_010*Yvel --important: use only in lerps or it might not work
  1868.     end
  1869.     local function getCamCF() --returns camera cframe
  1870.         return camcf
  1871.     end
  1872.     local function isFirstPerson() --returns true if user is in first person camera mode
  1873.         return firstperson
  1874.     end
  1875.  
  1876.     return {
  1877.         cframes=cframes,
  1878.         joints=joints,
  1879.         fling=predictionfling,
  1880.         predictionfling=predictionfling,
  1881.         refreshjoints=refreshjoints,
  1882.         raycastlegs=raycastlegs,
  1883.         velbycfrvec=velbycfrvec,
  1884.         velchgbycfrvec=velchgbycfrvec,
  1885.         velYchg=velYchg,
  1886.         addmode=addmode,
  1887.         getPart=getPart,
  1888.         getPartFromMesh=getPartFromMesh,
  1889.         getAccWeldFromMesh=getAccWeldFromMesh,
  1890.         getJoint=getJoint,
  1891.         getPartJoint=getPartJoint,
  1892.         rotToMouse=rotToMouse,
  1893.         glitchJoint=glitchJoint,
  1894.         setWalkSpeed=setWalkSpeed,
  1895.         setJumpPower=setJumpPower,
  1896.         setGravity=setGravity,
  1897.         setCfr=setCfr,
  1898.         getVel=getVel,
  1899.         getCamCF=getCamCF,
  1900.         isFirstPerson=isFirstPerson
  1901.     }
  1902. end
  1903.  
  1904. btn("Immortality Lord",function()
  1905.     local t=reanimate()
  1906.     if type(t)~="table" then return end
  1907.     local getJoint=t.getJoint
  1908.     local RootJoint=getJoint("RootJoint")
  1909.     local RightShoulder=getJoint("Right Shoulder")
  1910.     local LeftShoulder=getJoint("Left Shoulder")
  1911.     local RightHip=getJoint("Right Hip")
  1912.     local LeftHip=getJoint("Left Hip")
  1913.     local Neck=getJoint("Neck")
  1914.     local getVel=t.getVel
  1915.     local setCfr=t.setCfr
  1916.     local getCamCF=t.getCamCF
  1917.     local cframes=t.cframes
  1918.     local joints=t.joints
  1919.     local getAccWeldFromMesh=t.getAccWeldFromMesh
  1920.     local setWalkSpeed=t.setWalkSpeed
  1921.     local fling=t.fling
  1922.    
  1923.     setWalkSpeed(32)
  1924.     t.setJumpPower(0)
  1925.     t.setGravity(math.huge)
  1926.  
  1927.     local Gun={C0=cf_0}
  1928.     local Sword={C0=cf_0}
  1929.  
  1930.     local torso=t.getPart("Torso")
  1931.     local rootpart=t.getPart("HumanoidRootPart")
  1932.  
  1933.     local leftWingPart={}
  1934.     cframes[leftWingPart]=cf_0
  1935.  
  1936.     local leftWingAccWeld=getAccWeldFromMesh("17269814619","")
  1937.     leftWingAccWeld.C0=angles(0,3.14,0)
  1938.     leftWingAccWeld.C1=cf_0
  1939.     leftWingAccWeld.Part1=leftWingPart
  1940.  
  1941.     local LeftWing={
  1942.         C0=cf(-.3,1,1)*angles(0,rad(90),0),
  1943.         C1=cf(2.2,2,1.5),
  1944.         Part0=torso,
  1945.         Part1=leftWingPart
  1946.     }
  1947.     tinsert(joints,LeftWing)
  1948.    
  1949.     local rightWingPart={}
  1950.     cframes[rightWingPart]=cf_0
  1951.  
  1952.     local rightWingAccWeld=getAccWeldFromMesh("17269824947","")
  1953.     rightWingAccWeld.C0=angles(0,3.14,0)
  1954.     rightWingAccWeld.C1=cf_0
  1955.     rightWingAccWeld.Part1=rightWingPart
  1956.  
  1957.     local RightWing={
  1958.         C0=cf(.3,1,1)*angles(0,rad(90),0),
  1959.         C1=cf(2.2,2,-1.5),
  1960.         Part0=torso,
  1961.         Part1=rightWingPart
  1962.     }
  1963.     tinsert(joints,RightWing)
  1964.    
  1965.     local swordpart={}
  1966.     cframes[swordpart]=cf_0
  1967.    
  1968.     local swordAccWeld0=getAccWeldFromMesh("17326555172","")
  1969.     swordAccWeld0.C0=cf(-0.0023765564,2.14191723,3.825109,-1,0,0,0,-0.519688249,-0.85435611,0,-0.854355931,0.519688308)
  1970.     swordAccWeld0.C1=cf_0
  1971.     swordAccWeld0.Part1=swordpart
  1972.     local swordAccWeld1=getAccWeldFromMesh("17326476901","")
  1973.     swordAccWeld1.C0=cf(-0.00237464905,-1.31204176,-3.18902349,-1,0,0,0,-0.519688249,-0.85435611,0,-0.854355931,0.519688308)
  1974.     swordAccWeld1.C1=cf_0
  1975.     swordAccWeld1.Part1=swordpart
  1976.    
  1977.     local Sword={
  1978.         C0=cf(0,-2,0)*angles(1.57,0,0),
  1979.         C1=cf(0,-6.3,0),
  1980.         Part0=t.getPart("Right Arm"),
  1981.         Part1=swordpart
  1982.     }
  1983.     tinsert(joints,Sword)
  1984.  
  1985.     local DefaultsNeckC0 = cf(0,2,0)*angles(rad(-90),0,rad(180))
  1986.     local DefaultsRootJointC0 = angles(rad(-90),0,rad(180))
  1987.     local DefaultsRightShoulderC0 = cf(-1,0,0)*angles(0,rad(90),0)
  1988.     local DefaultsLeftShoulderC0 = cf(1,0,0)*angles(0,rad(-90),0)
  1989.  
  1990.     local TimingSine=sine*60
  1991.     local attacking=false
  1992.     local animOverwrite=nil
  1993.     local neckSnap=false
  1994.  
  1995.     local function Lerp1(a,b,c)
  1996.         return Lerp(a,b,min(c*6*deltaTime,1))
  1997.     end
  1998.  
  1999.     local v3_030=v3_010*3
  2000.     local flycf=nil
  2001.     local flypos=nil
  2002.     local charcf=cf_0
  2003.     local function animations(onground)    
  2004.         TimingSine=sine*60
  2005.         local vel=getVel()
  2006.         local xzvel=vel*v3_101
  2007.         if flycf then
  2008.             if xzvel~=v3_0 then
  2009.                 local camrot=cfGet(getCamCF(),"Rotation")
  2010.                 local clv=cfGet(camrot,"LookVector")
  2011.                 local crv=cfGet(camrot,"RightVector")
  2012.                 local fw=v3Get(clv*v3_101,"Unit")*xzvel
  2013.                 fw=clv*(v3Get(fw,"X")+v3Get(fw,"Z"))
  2014.                 local rt=v3Get(crv*v3_101,"Unit")*xzvel
  2015.                 rt=crv*(v3Get(rt,"X")+v3Get(rt,"Z"))
  2016.                 flypos=flypos+v3Get(fw+rt,"Unit")*deltaTime*3.2
  2017.                 flycf=cfAdd(camrot,flypos)
  2018.                 charcf=cfAdd(flycf,cfGet(flycf,"UpVector")*3-v3_030)
  2019.             end
  2020.             cframes[rootpart]=flycf
  2021.             setCfr(charcf)
  2022.         elseif onground then
  2023.             charcf=cframes[rootpart]
  2024.         elseif cframes[rootpart].Y<charcf.Y then
  2025.             local newcf=cframes[rootpart]
  2026.             local lastY=cfGet(charcf,"Y")
  2027.             charcf=cfAdd(cfGet(newcf,"Rotation"),v3(cfGet(newcf,"X"),lastY+(cfGet(newcf,"Y")-lastY)*deltaTime*0.6,cfGet(newcf,"Z")))
  2028.             cframes[rootpart]=charcf
  2029.             setCfr(charcf)
  2030.         else
  2031.             charcf=cframes[rootpart]
  2032.         end
  2033.         if attacking then
  2034.             animOverwrite()
  2035.         elseif xzvel~=v3_0 then
  2036.             if neckSnap then
  2037.                 Neck.C0 = DefaultsNeckC0
  2038.                 neckSnap = false
  2039.             else
  2040.                 Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2041.             end
  2042.             if mrandom(15) == 1 then
  2043.                 Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2044.                 neckSnap = true
  2045.             end
  2046.             if onground and not flycf then
  2047.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(-10),0,0)*DefaultsRightShoulderC0,.25)
  2048.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-2,0)*angles(rad(154.35-5.65*sin(TimingSine/25)),0,0),.25)
  2049.             else
  2050.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80+5*cos(TimingSine/25)),0,rad(45))*DefaultsRightShoulderC0,.25)
  2051.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-0,-1)*angles(0,rad(170),rad(-10)),.25)
  2052.             end
  2053.             RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-sin(TimingSine/25))*angles(rad(20),0,0),.25)
  2054.             LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(20),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2055.             RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2056.             LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2057.         else
  2058.             RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-sin(TimingSine/25))*angles(rad(20),0,0),.25)
  2059.             if neckSnap then
  2060.                 Neck.C0 = DefaultsNeckC0*angles(rad(20),rad(10*sin(TimingSine/50)),0)
  2061.                 neckSnap = false
  2062.             else
  2063.                 Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0*angles(rad(20),rad(10*sin(TimingSine/50)),0),.25)
  2064.             end
  2065.             if mrandom(15) == 1 then
  2066.                 Neck.C0 = DefaultsNeckC0*angles(rad(20+mrandom(-20,20)),rad((10*sin(TimingSine/50))+mrandom(-20,20)),rad(mrandom(-20,20)))
  2067.                 neckSnap = true
  2068.             end
  2069.             if onground and not flycf then
  2070.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(-10),0,0)*DefaultsRightShoulderC0,.25)
  2071.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-2,0)*angles(rad(154.35-5.65*sin(TimingSine/25)),0,0),.25)
  2072.             else
  2073.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80+5*cos(TimingSine/25)),0,rad(45))*DefaultsRightShoulderC0,.25)
  2074.                 Sword.C0 = Lerp1(Sword.C0,cf(0,0,-1)*angles(0,rad(170),rad(-10)),.25)
  2075.             end
  2076.             LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(20),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2077.             RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(10),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2078.             LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(20),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2079.         end
  2080.         RightWing.C0 = Lerp1(RightWing.C0,cf(0.3,1,1)*angles(0,rad(105-25*cos(TimingSine/25)),0),.25)
  2081.         LeftWing.C0 = Lerp1(LeftWing.C0,cf(-0.3,1,1)*angles(0,rad(75+25*cos(TimingSine/25)),0),.25)
  2082.     end
  2083.    
  2084.     local function onKeyPressed(key)
  2085.         if key=="f" then
  2086.             if flycf then
  2087.                 flycf=nil
  2088.                 charcf=cf(flypos)
  2089.                 setCfr(charcf)
  2090.             else
  2091.                 flypos=cfGet(cframes[rootpart],"Position")
  2092.                 flycf=cf(flypos)
  2093.                 charcf=flycf
  2094.             end
  2095.         elseif key=="z" then
  2096.             if attacking then return end
  2097.             attacking=true
  2098.             setWalkSpeed(0)
  2099.             animOverwrite=function()
  2100.                 RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-sin(TimingSine/25))*angles(rad(5),0,rad(-20)),.25)
  2101.                 if neckSnap then
  2102.                     Neck.C0 = DefaultsNeckC0
  2103.                     neckSnap = false
  2104.                 else
  2105.                     Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2106.                 end
  2107.                 if mrandom(15) == 1 then
  2108.                     Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2109.                     neckSnap = true
  2110.                 end
  2111.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80),0,rad(50))*DefaultsRightShoulderC0,.25)
  2112.                 Sword.C0 = Lerp1(Sword.C0,cf(-1,-1,0)*angles(rad(180),rad(-90),0),.25)
  2113.                 LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(5),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2114.                 RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2115.                 LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2116.             end
  2117.             twait(0.25)
  2118.             local flingpos=cfGet(cfMul(cframes[rootpart],cf(0,0,-9)),"Position")
  2119.             for i,v in next,GetDescendants(ws) do
  2120.                 if IsA(v,"Humanoid") then
  2121.                     local p=v.Parent
  2122.                     p=gp(p,"HumanoidRootPart","BasePart") or FindFirstChildWhichIsA(p,"BasePart")
  2123.                     if p and (v3Get(insGet(p,"Position")-flingpos,"Magnitude")<9) then
  2124.                         fling(v)
  2125.                     end
  2126.                 end
  2127.             end
  2128.             animOverwrite=function()
  2129.                 RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-sin(TimingSine/25))*angles(rad(5),0,rad(20)),.25)
  2130.                 if neckSnap then
  2131.                     Neck.C0 = DefaultsNeckC0
  2132.                     neckSnap = false
  2133.                 else
  2134.                     Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2135.                 end
  2136.                 if mrandom(15) == 1 then
  2137.                     Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2138.                     neckSnap = true
  2139.                 end
  2140.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(2,1,-1)*angles(rad(80),0,rad(-50))*DefaultsRightShoulderC0,.25)
  2141.                 Sword.C0 = Lerp1(Sword.C0,cf(-1,-1,0)*angles(rad(180),rad(-90),0),.25)
  2142.                 LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(5),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2143.                 RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2144.                 LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2145.             end
  2146.             twait(0.25)
  2147.             setWalkSpeed(32)
  2148.             attacking=false
  2149.         elseif key=="x" then
  2150.             attacking=true
  2151.             setWalkSpeed(0)
  2152.             local newpos=cfGet(insGet(mouse,"Hit"),"Position")+v3_010*10
  2153.             local newcf=cfl(newpos,newpos+cfGet(getCamCF(),"LookVector")*v3_101)
  2154.             animOverwrite=function()
  2155.                 RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-sin(TimingSine/25))*angles(rad(20),0,0),.25)
  2156.                 if neckSnap then
  2157.                     Neck.C0 = DefaultsNeckC0
  2158.                     neckSnap = false
  2159.                 else
  2160.                     Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2161.                 end
  2162.                 if mrandom(15) == 1 then
  2163.                     Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2164.                     neckSnap = true
  2165.                 end
  2166.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80+5*cos(TimingSine/25)),0,rad(45))*DefaultsRightShoulderC0,.25)
  2167.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-0,-1)*angles(0,rad(170),rad(-10)),.25)
  2168.                 LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(20),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2169.                 RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2170.                 LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2171.             end
  2172.             twait(0.5)
  2173.             local animStart=sine
  2174.             animOverwrite=function()
  2175.                 RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,-20*(.5+sine-animStart))*angles(rad(20),0,0),.25)
  2176.                 if neckSnap then
  2177.                     Neck.C0 = DefaultsNeckC0
  2178.                     neckSnap = false
  2179.                 else
  2180.                     Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2181.                 end
  2182.                 if mrandom(15) == 1 then
  2183.                     Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2184.                     neckSnap = true
  2185.                 end
  2186.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80+5*cos(TimingSine/25)),0,rad(45))*DefaultsRightShoulderC0,.25)
  2187.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-0,-1)*angles(0,rad(170),rad(-10)),.25)
  2188.                 LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(20),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2189.                 RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2190.                 LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2191.             end
  2192.             twait(0.5)
  2193.             if flycf then
  2194.                 flycf=newcf
  2195.                 flypos=newpos
  2196.             end
  2197.             charcf=newcf
  2198.             setCfr(newcf)
  2199.            
  2200.             twait(0.5)
  2201.             animStart=sine
  2202.            
  2203.             animOverwrite=function()
  2204.                 RootJoint.C0 = Lerp1(RootJoint.C0,DefaultsRootJointC0*cf(0,0,(-sin(TimingSine/25))-(10-(sine-animStart)*20))*angles(rad(20),0,0),.25)
  2205.                 if neckSnap then
  2206.                     Neck.C0 = DefaultsNeckC0
  2207.                     neckSnap = false
  2208.                 else
  2209.                     Neck.C0 = Lerp1(Neck.C0,DefaultsNeckC0,.25)
  2210.                 end
  2211.                 if mrandom(15) == 1 then
  2212.                     Neck.C0 = DefaultsNeckC0*angles(rad(mrandom(-20,20)),rad(mrandom(-20,20)),rad(mrandom(-20,20)))
  2213.                     neckSnap = true
  2214.                 end
  2215.                 RightShoulder.C0 = Lerp1(RightShoulder.C0,cf(3,1,0)*angles(rad(80+5*cos(TimingSine/25)),0,rad(45))*DefaultsRightShoulderC0,.25)
  2216.                 Sword.C0 = Lerp1(Sword.C0,cf(0,-0,-1)*angles(0,rad(170),rad(-10)),.25)
  2217.                 LeftShoulder.C0 = Lerp1(LeftShoulder.C0,cf(-3,1,0)*angles(rad(20),0,rad(-10-10*cos(TimingSine/25)))*DefaultsLeftShoulderC0,.25)
  2218.                 RightHip.C0 = Lerp1(RightHip.C0,cf(2,-2,0)*angles(rad(-20),rad(80),rad(10+10*cos(TimingSine/25))),.25)
  2219.                 LeftHip.C0 = Lerp1(LeftHip.C0,cf(-2,-2,0)*angles(rad(-10),rad(-80),rad(-10-10*cos(TimingSine/25))),.25)
  2220.             end
  2221.             twait(0.5)
  2222.             setWalkSpeed(32)
  2223.             attacking=false
  2224.         end
  2225.     end
  2226.    
  2227.     local function animations1()
  2228.         animations(true)
  2229.     end
  2230.     local function animations0()
  2231.         animations(false)
  2232.     end
  2233.     local lastmode="default"
  2234.     t.addmode("default",{
  2235.         modeEntered=function()
  2236.             onKeyPressed(lastmode)
  2237.             lastmode="default"
  2238.         end,
  2239.         idle=animations1,walk=animations1,jump=animations0,fall=animations0
  2240.     })
  2241.     t.addmode("z",{
  2242.         modeEntered=function()
  2243.             onKeyPressed("z")
  2244.             lastmode="z"
  2245.         end,
  2246.         idle=animations1,walk=animations1,jump=animations0,fall=animations0
  2247.     })
  2248.     t.addmode("x",{
  2249.         modeEntered=function()
  2250.             onKeyPressed("x")
  2251.             lastmode="x"
  2252.         end,
  2253.         idle=animations1,walk=animations1,jump=animations0,fall=animations0
  2254.     })
  2255.     t.addmode("f",{
  2256.         modeEntered=function()
  2257.             onKeyPressed("f")
  2258.             lastmode="f"
  2259.         end,
  2260.         idle=animations1,walk=animations1,jump=animations0,fall=animations0
  2261.     })
  2262. end)
  2263.  
  2264.  
  2265.  
  2266. btn("empty reanimate (no animations)", reanimate)
  2267. insSet(btn("stop current script",stopreanimate),"TextColor3",c3(0.75,0,0))
  2268.  
  2269. lbl("SETTINGS (REANIMATE TO APPLY)")
  2270.  
  2271. local function swtc(txt,options,onchanged)
  2272.     local current=0
  2273.     local swtcbtn=nil
  2274.     local function btnpressed()
  2275.         current=current+1
  2276.         if current>#options then
  2277.             current=1
  2278.         end
  2279.         local option=options[current]
  2280.         insSet(swtcbtn,"Text",txt..": "..option.text)
  2281.         onchanged(option.value)
  2282.     end
  2283.     swtcbtn=btn("change",btnpressed)
  2284.     btnpressed()
  2285.     return swtcbtn
  2286. end
  2287.  
  2288. swtc("client sided placeholders",{
  2289.     {value=true,text="yes"},
  2290.     {value=false,text="no"}
  2291. },function(v)
  2292.     placeholders=v
  2293. end)
  2294.  
  2295. swtc("highlight fling targets",{
  2296.     {value=true,text="yes"},
  2297.     {value=false,text="no"}
  2298. },function(v)
  2299.     highlightflingtargets=v
  2300. end)
  2301.  
  2302. swtc("allow shiftlock",{
  2303.     {value=true,text="yes"},
  2304.     {value=false,text="no"}
  2305. },function(v)
  2306.     allowshiftlock=v
  2307. end)
  2308.  
  2309. swtc("ctrl click tp",{
  2310.     {value=false,text="no"},
  2311.     {value=true,text="yes"}
  2312. },function(v)
  2313.     ctrltp=v
  2314. end)
  2315.  
  2316. swtc("click fling",{
  2317.     {value=false,text="no"},
  2318.     {value=true,text="yes"}
  2319. },function(v)
  2320.     clickfling=v
  2321. end)
  2322.  
  2323. swtc("changestate when fling",{
  2324.     {value=true,text="yes"},
  2325.     {value=false,text="no"}
  2326. },function(v)
  2327.     flingchangestate=v
  2328. end)
  2329. lbl("(limb collision)")
  2330.  
  2331. swtc("respawn tp",{
  2332.     {value=true,text="random tp close"},
  2333.     {value=false,text="stay at spawn"}
  2334. },function(v)
  2335.     respawntp=v
  2336. end)
  2337.  
  2338. local disguiscripts=nil
  2339. swtc("new gui scripts",{
  2340.     {value=true,text="disable"},
  2341.     {value=false,text="keep"}
  2342. },function(v)
  2343.     disguiscripts=v
  2344. end)
  2345. Connect(insGet(pg,"DescendantAdded"),function(v)
  2346.     if c and disguiscripts and IsA(v,"Script") then --mind Enum.RunContext.Client
  2347.         insSet(v,"Disabled",true)
  2348.     end
  2349. end)
  2350.  
  2351. swtc("new character scripts",{
  2352.     {value=function(v)
  2353.         if IsA(v,"Script") then --mind Enum.RunContext.Client
  2354.             insSet(v,"Disabled",true)
  2355.         end
  2356.     end,text="disable"},
  2357.     {value=false,text="keep"}
  2358. },function(v)
  2359.     discharscripts=v
  2360. end)
  2361.  
  2362. swtc("breakjoints",{
  2363.     {value=1,text="breakjoints+health"},
  2364.     {value=2,text="health or breakjoints"},
  2365.     {value=3,text="breakjoints"}
  2366. },function(v)
  2367.     breakjointsmethod=v
  2368. end)
  2369.  
  2370. local iscg,_=pcall(insSet,i10,"Parent",FindFirstChildOfClass(game,"CoreGui"))
  2371. if not iscg then
  2372.     insSet(i7,"Text","PLAYERGUI MODE")
  2373.     insSet(i10,"Parent",pg)
  2374.     twait(3)
  2375.     insSet(i7,"Text",guiTheme.guiTitle)
  2376. end
Add Comment
Please, Sign In to add comment