Advertisement
Zulkin

Hat Flinging scripts - Reanim

Dec 24th, 2022 (edited)
1,195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.71 KB | None | 0 0
  1. -- MyWorld
  2. local healthHide = false --moves your head away every 3 seconds so players dont see your health bar (alignmode 4 only)
  3. local reclaim = true --if you lost control over a part this will move your primary part to the part so you get it back (alignmode 4)
  4. local novoid = true --prevents parts from going under workspace.FallenPartsDestroyHeight if you control them (alignmode 4 only)
  5. local physp = PhysicalProperties.new(0.01, 0, 1, 0, 0) --sets .CustomPhysicalProperties to this for each part
  6. local noclipAllParts = false --set it to true if you want noclip
  7. local antiragdoll = true --removes hingeConstraints and ballSocketConstraints from your character
  8. local newanimate = true--disables the animate script and enables after reanimation
  9. local discharscripts = true --disables all localScripts parented to your character before reanimation
  10. local R15toR6 = true --tries to convert your character to r6 if its r15
  11. local hatcollide = false --makes hats cancollide (credit to ShownApe) (works only with reanimate method 0)
  12. local humState16 = true --enables collisions for limbs before the humanoid dies (using hum:ChangeState)
  13. local addtools = false --puts all tools from backpack to character and lets you hold them after reanimation
  14. local hedafterneck = false --disable aligns for head and enable after neck or torso is removed
  15. local simrad = math.huge --simulation radius with sethiddenproperty (nil to disable)
  16. local loadtime = game:GetService("Players").RespawnTime + 0.5 --anti respawn delay
  17. local method = 0 --reanimation method
  18. --methods:
  19. --0 - breakJoints (takes [loadtime] seconds to load)
  20. --1 - limbs
  21. --2 - limbs + anti respawn
  22. --3 - limbs + breakJoints after [loadtime] seconds
  23. --4 - remove humanoid + breakJoints
  24. --5 - remove humanoid + limbs
  25. local alignmode = 4 --AlignPosition mode
  26. --modes:
  27. --1 - AlignPosition rigidity enabled true
  28. --2 - 2 AlignPositions rigidity enabled both true and false
  29. --3 - AlignPosition rigidity enabled false
  30. --4 - no AlignPosition, CFrame only
  31. local flingpart = "Head" --name of the part or the hat used for flinging
  32. --the fling function
  33. --usage: fling(target, duration, velocity)
  34. --target can be set to: basePart, CFrame, Vector3, character model or humanoid (flings at mouse.Hit if argument not provided)
  35. --duration (fling time in seconds) can be set to a number or a string convertable to a number (0.5s if not provided)
  36. --velocity (fling part rotation velocity) can be set to a vector3 value (Vector3.new(20000, 20000, 20000) if not provided)
  37.  
  38. local lp = game:GetService("Players").LocalPlayer
  39. local rs, ws, sg = game:GetService("RunService"), game:GetService("Workspace"), game:GetService("StarterGui")
  40. local stepped, heartbeat, renderstepped = rs.Stepped, rs.Heartbeat, rs.RenderStepped
  41. local twait, tdelay, rad, inf, abs, mclamp = task.wait, task.delay, math.rad, math.huge, math.abs, math.clamp
  42. local cf, v3, angles = CFrame.new, Vector3.new, CFrame.Angles
  43. local v3_0, cf_0 = v3(0, 0, 0), cf(0, 0, 0)
  44. local swait = function(amnt) if amnt == nil or 0 then renderstepped:wait(math.clamp(0, -0.00000000001, 0.00000000001)) else renderstepped:wait(amnt) end end
  45.  
  46. local c = lp.Character
  47. if not (c and c.Parent) then
  48.     return
  49. end
  50.  
  51. c:GetPropertyChangedSignal("Parent"):Connect(function()
  52.     if not (c and c.Parent) then
  53.         c = nil
  54.     end
  55. end)
  56.  
  57. local destroy = c.Destroy
  58.  
  59. local function gp(parent, name, className)
  60.     if typeof(parent) == "Instance" then
  61.         for i, v in pairs(parent:GetChildren()) do
  62.             if (v.Name == name) and v:IsA(className) then
  63.                 return v
  64.             end
  65.         end
  66.     end
  67.     return nil
  68. end
  69.  
  70. local v3_xz, v3_net = v3(8, 0, 8), v3(0.1, 25.1, 0.1)
  71. local function getNetlessVelocity(realPartVelocity) --edit this if you have a better netless method
  72.     if realPartVelocity.Magnitude < 0.1 then return v3_net end
  73.     return realPartVelocity * v3_xz + v3_net
  74. end
  75.  
  76. if type(simrad) == "number" then
  77.     local shp = getfenv().sethiddenproperty
  78.     if shp then
  79.         local con = nil
  80.         con = heartbeat:Connect(function()
  81.             if not c then return con:Disconnect() end
  82.             shp(lp, "SimulationRadius", simrad)
  83.         end)
  84.     end
  85. end
  86.  
  87. healthHide = healthHide and ((method == 0) or (method == 2) or (method == 3)) and gp(c, "Head", "BasePart")
  88.  
  89. local reclaim, lostpart = reclaim and c.PrimaryPart, nil
  90.  
  91. local v3_hide = v3(0, 3000, 0)
  92. local function align(Part0, Part1)
  93.  
  94.     local att0 = Instance.new("Attachment")
  95.     att0.Position, att0.Orientation, att0.Name = v3_0, v3_0, "att0_" .. Part0.Name
  96.     local att1 = Instance.new("Attachment")
  97.     att1.Position, att1.Orientation, att1.Name = v3_0, v3_0, "att1_" .. Part1.Name
  98.  
  99.     if alignmode == 4 then
  100.  
  101.         local hide = false
  102.         if Part0 == healthHide then
  103.             healthHide = false
  104.             tdelay(0, function()
  105.                 while twait(2.9) and Part0 and c do
  106.                     hide = #Part0:GetConnectedParts() == 1
  107.                     twait(0.1)
  108.                     hide = false
  109.                 end
  110.             end)
  111.         end
  112.  
  113.         local rot = rad(0.05)
  114.         local con0, con1 = nil, nil
  115.         con0 = stepped:Connect(function()
  116.             if not (Part0 and Part1) then return con0:Disconnect() and con1:Disconnect() end
  117.             Part0.RotVelocity = Part1.RotVelocity
  118.         end)
  119.         local lastpos, vel = Part0.Position, Part0.Velocity
  120.         con1 = heartbeat:Connect(function(delta)
  121.             if not (Part0 and Part1 and att1) then return con0:Disconnect() and con1:Disconnect() end
  122.             if (not Part0.Anchored) and (Part0.ReceiveAge == 0) then
  123.                 if lostpart == Part0 then
  124.                     lostpart = nil
  125.                 end
  126.                 local newcf = Part1.CFrame * att1.CFrame
  127.                 local vel = (newcf.Position - lastpos) / delta
  128.                 Part0.Velocity = getNetlessVelocity(vel)
  129.                 if vel.Magnitude < 1 then
  130.                     rot = -rot
  131.                     newcf *= angles(0, 0, rot)
  132.                 end
  133.                 lastpos = newcf.Position
  134.                 if lostpart and (Part0 == reclaim) then
  135.                     newcf = lostpart.CFrame
  136.                 elseif hide then
  137.                     newcf += v3_hide
  138.                 end
  139.                 if novoid and (newcf.Y < ws.FallenPartsDestroyHeight + 0.1) then
  140.                     newcf += v3(0, ws.FallenPartsDestroyHeight + 0.1 - newcf.Y, 0)
  141.                 end
  142.                 Part0.CFrame = newcf
  143.             elseif (not Part0.Anchored) and (abs(Part0.Velocity.X) < 45) and (abs(Part0.Velocity.Y) < 25) and (abs(Part0.Velocity.Z) < 45) then
  144.                 lostpart = Part0
  145.             end
  146.         end)
  147.  
  148.     else
  149.  
  150.         Part0.CustomPhysicalProperties = physp
  151.         if (alignmode == 1) or (alignmode == 2) then
  152.             local ape = Instance.new("AlignPosition")
  153.             ape.MaxForce, ape.MaxVelocity, ape.Responsiveness = inf, inf, inf
  154.             ape.ReactionForceEnabled, ape.RigidityEnabled, ape.ApplyAtCenterOfMass = false, true, false
  155.             ape.Attachment0, ape.Attachment1, ape.Name = att0, att1, "AlignPositionRtrue"
  156.             ape.Parent = att0
  157.         end
  158.  
  159.         if (alignmode == 2) or (alignmode == 3) then
  160.             local apd = Instance.new("AlignPosition")
  161.             apd.MaxForce, apd.MaxVelocity, apd.Responsiveness = inf, inf, inf
  162.             apd.ReactionForceEnabled, apd.RigidityEnabled, apd.ApplyAtCenterOfMass = false, false, false
  163.             apd.Attachment0, apd.Attachment1, apd.Name = att0, att1, "AlignPositionRfalse"
  164.             apd.Parent = att0
  165.         end
  166.  
  167.         local ao = Instance.new("AlignOrientation")
  168.         ao.MaxAngularVelocity, ao.MaxTorque, ao.Responsiveness = inf, inf, inf
  169.         ao.PrimaryAxisOnly, ao.ReactionTorqueEnabled, ao.RigidityEnabled = false, false, false
  170.         ao.Attachment0, ao.Attachment1 = att0, att1
  171.         ao.Parent = att0
  172.  
  173.         local con0, con1 = nil, nil
  174.         local vel = Part0.Velocity
  175.         con0 = renderstepped:Connect(function()
  176.             if not (Part0 and Part1) then return con0:Disconnect() and con1:Disconnect() end
  177.             if Part0 then Part0.Velocity = Vector3.new(0,0,0) end
  178.         end)
  179.         local lastpos = Part0.Position
  180.         con1 = heartbeat:Connect(function(delta)
  181.             if not (Part0 and Part1) then return con0:Disconnect() and con1:Disconnect() end
  182.             vel = Part0.Velocity
  183.             Part0.Velocity = getNetlessVelocity((Part1.Position - lastpos) / delta)
  184.             lastpos = Part1.Position
  185.         end)
  186.  
  187.     end
  188.  
  189.     att0:GetPropertyChangedSignal("Parent"):Connect(function()
  190.         Part0 = att0.Parent
  191.         if not Part0:IsA("BasePart") then
  192.             att0 = nil
  193.             if lostpart == Part0 then
  194.                 lostpart = nil
  195.             end
  196.             Part0 = nil
  197.         end
  198.     end)
  199.     att0.Parent = Part0
  200.  
  201.     att1:GetPropertyChangedSignal("Parent"):Connect(function()
  202.         Part1 = att1.Parent
  203.         if not Part1:IsA("BasePart") then
  204.             att1 = nil
  205.             Part1 = nil
  206.         end
  207.     end)
  208.     att1.Parent = Part1
  209. end
  210.  
  211. local function respawnrequest()
  212.     local ccfr, c = ws.CurrentCamera.CFrame, lp.Character
  213.     lp.Character = nil
  214.     lp.Character = c
  215.     local con = nil
  216.     con = ws.CurrentCamera.Changed:Connect(function(prop)
  217.         if (prop ~= "Parent") and (prop ~= "CFrame") then
  218.             return
  219.         end
  220.         ws.CurrentCamera.CFrame = ccfr
  221.         con:Disconnect()
  222.     end)
  223. end
  224.  
  225. local destroyhum = (method == 4) or (method == 5)
  226. local breakjoints = (method == 0) or (method == 4)
  227. local antirespawn = (method == 0) or (method == 2) or (method == 3)
  228.  
  229. hatcollide = hatcollide and (method == 0)
  230.  
  231. addtools = addtools and lp:FindFirstChildOfClass("Backpack")
  232.  
  233. if antiragdoll then
  234.     antiragdoll = function(v)
  235.         if v:IsA("HingeConstraint") or v:IsA("BallSocketConstraint") then
  236.             v.Parent = nil
  237.         end
  238.     end
  239.     for i, v in pairs(c:GetDescendants()) do
  240.         antiragdoll(v)
  241.     end
  242.     c.DescendantAdded:Connect(antiragdoll)
  243. end
  244.  
  245. if antirespawn then
  246.     respawnrequest()
  247. end
  248.  
  249. if method == 0 then
  250.     twait(loadtime)
  251.     if not c then
  252.         return
  253.     end
  254. end
  255.  
  256. if discharscripts then
  257.     for i, v in pairs(c:GetDescendants()) do
  258.         if v:IsA("LocalScript") then
  259.             v.Disabled = true
  260.         end
  261.     end
  262. elseif newanimate then
  263.     local animate = gp(c, "Animate", "LocalScript")
  264.     if animate and (not animate.Disabled) then
  265.         animate.Disabled = true
  266.     else
  267.         newanimate = false
  268.     end
  269. end
  270.  
  271. if addtools then
  272.     for i, v in pairs(addtools:GetChildren()) do
  273.         if v:IsA("Tool") then
  274.             v.Parent = c
  275.         end
  276.     end
  277. end
  278.  
  279. pcall(function()
  280.     settings().Physics.AllowSleep = false
  281.     settings().Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.Disabled
  282. end)
  283.  
  284. local OLDscripts = {}
  285.  
  286. for i, v in pairs(c:GetDescendants()) do
  287.     if v.ClassName == "Script" then
  288.         OLDscripts[v.Name] = true
  289.     end
  290. end
  291.  
  292. local scriptNames = {}
  293.  
  294. for i, v in pairs(c:GetDescendants()) do
  295.     if v:IsA("BasePart") then
  296.         local newName, exists = tostring(i), true
  297.         while exists do
  298.             exists = OLDscripts[newName]
  299.             if exists then
  300.                 newName = newName .. "_"    
  301.             end
  302.         end
  303.         table.insert(scriptNames, newName)
  304.         Instance.new("Script", v).Name = newName
  305.     end
  306. end
  307.  
  308. local hum = c:FindFirstChildOfClass("Humanoid")
  309. if hum then
  310.     for i, v in pairs(hum:GetPlayingAnimationTracks()) do
  311.         v:Stop()
  312.     end
  313. end
  314. c.Archivable = true
  315. local cl = c:Clone()
  316. if hum and humState16 then
  317.     hum:ChangeState(Enum.HumanoidStateType.Physics)
  318.     if destroyhum then
  319.         twait(1.6)
  320.     end
  321. end
  322. if destroyhum then
  323.     pcall(destroy, hum)
  324. end
  325.  
  326. if not c then
  327.     return
  328. end
  329.  
  330. local head, torso, root = gp(c, "Head", "BasePart"), gp(c, "Torso", "BasePart") or gp(c, "UpperTorso", "BasePart"), gp(c, "HumanoidRootPart", "BasePart")
  331. if hatcollide then
  332.     pcall(destroy, torso)
  333.     pcall(destroy, root)
  334.     pcall(destroy, c:FindFirstChildOfClass("BodyColors") or gp(c, "Health", "Script"))
  335. end
  336.  
  337. local model = Instance.new("Model", c)
  338. model:GetPropertyChangedSignal("Parent"):Connect(function()
  339.     if not (model and model.Parent) then
  340.         model = nil
  341.     end
  342. end)
  343.  
  344. for i, v in pairs(c:GetChildren()) do
  345.     if v ~= model then
  346.         if addtools and v:IsA("Tool") then
  347.             for i1, v1 in pairs(v:GetDescendants()) do
  348.                 if v1 and v1.Parent and v1:IsA("BasePart") then
  349.                     local bv = Instance.new("BodyVelocity")
  350.                     bv.Velocity, bv.MaxForce, bv.P, bv.Name = v3_0, v3(1000, 1000, 1000), 1250, "bv_" .. v.Name
  351.                     bv.Parent = v1
  352.                 end
  353.             end
  354.         end
  355.         v.Parent = model
  356.     end
  357. end
  358.  
  359. if breakjoints then
  360.     model:BreakJoints()
  361. else
  362.     if head and torso then
  363.         for i, v in pairs(model:GetDescendants()) do
  364.             if v:IsA("JointInstance") then
  365.                 local save = false
  366.                 if (v.Part0 == torso) and (v.Part1 == head) then
  367.                     save = true
  368.                 end
  369.                 if (v.Part0 == head) and (v.Part1 == torso) then
  370.                     save = true
  371.                 end
  372.                 if save then
  373.                     if hedafterneck then
  374.                         hedafterneck = v
  375.                     end
  376.                 else
  377.                     pcall(destroy, v)
  378.                 end
  379.             end
  380.         end
  381.     end
  382.     if method == 3 then
  383.         task.delay(loadtime, pcall, model.BreakJoints, model)
  384.     end
  385. end
  386.  
  387. cl.Parent = ws
  388. for i, v in pairs(cl:GetChildren()) do
  389.     v.Parent = c
  390. end
  391. pcall(destroy, cl)
  392.  
  393. local uncollide, noclipcon = nil, nil
  394. if noclipAllParts then
  395.     uncollide = function()
  396.         if c then
  397.             for i, v in pairs(c:GetDescendants()) do
  398.                 if v:IsA("BasePart") then
  399.                     v.CanCollide = false
  400.                 end
  401.             end
  402.         else
  403.             noclipcon:Disconnect()
  404.         end
  405.     end
  406. else
  407.     uncollide = function()
  408.         if model then
  409.             for i, v in pairs(model:GetDescendants()) do
  410.                 if v:IsA("BasePart") then
  411.                     v.CanCollide = false
  412.                 end
  413.             end
  414.         else
  415.             noclipcon:Disconnect()
  416.         end
  417.     end
  418. end
  419. noclipcon = stepped:Connect(uncollide)
  420. uncollide()
  421.  
  422. for i, scr in pairs(model:GetDescendants()) do
  423.     if (scr.ClassName == "Script") and table.find(scriptNames, scr.Name) then
  424.         local Part0 = scr.Parent
  425.         if Part0:IsA("BasePart") then
  426.             for i1, scr1 in pairs(c:GetDescendants()) do
  427.                 if (scr1.ClassName == "Script") and (scr1.Name == scr.Name) and (not scr1:IsDescendantOf(model)) then
  428.                     local Part1 = scr1.Parent
  429.                     if (Part1.ClassName == Part0.ClassName) and (Part1.Name == Part0.Name) then
  430.                         align(Part0, Part1)
  431.                         pcall(destroy, scr)
  432.                         pcall(destroy, scr1)
  433.                         break
  434.                     end
  435.                 end
  436.             end
  437.         end
  438.     end
  439. end
  440.  
  441. for i, v in pairs(c:GetDescendants()) do
  442.     if v and v.Parent and (not v:IsDescendantOf(model)) then
  443.         if v:IsA("Decal") then
  444.             v.Transparency = 1
  445.         elseif v:IsA("BasePart") then
  446.             v.Transparency = 1
  447.             v.Anchored = false
  448.         elseif v:IsA("ForceField") then
  449.             v.Visible = false
  450.         elseif v:IsA("Sound") then
  451.             v.Playing = false
  452.         elseif v:IsA("BillboardGui") or v:IsA("SurfaceGui") or v:IsA("ParticleEmitter") or v:IsA("Fire") or v:IsA("Smoke") or v:IsA("Sparkles") then
  453.             v.Enabled = false
  454.         end
  455.     end
  456. end
  457.  
  458. if newanimate then
  459.     local animate = gp(c, "Animate", "LocalScript")
  460.     if animate then
  461.         animate.Disabled = false
  462.     end
  463. end
  464.  
  465. if addtools then
  466.     for i, v in pairs(c:GetChildren()) do
  467.         if v:IsA("Tool") then
  468.             v.Parent = addtools
  469.         end
  470.     end
  471. end
  472.  
  473. local hum0, hum1 = model:FindFirstChildOfClass("Humanoid"), c:FindFirstChildOfClass("Humanoid")
  474. if hum0 then
  475.     hum0:GetPropertyChangedSignal("Parent"):Connect(function()
  476.         if not (hum0 and hum0.Parent) then
  477.             hum0 = nil
  478.         end
  479.     end)
  480. end
  481. if hum1 then
  482.     hum1:GetPropertyChangedSignal("Parent"):Connect(function()
  483.         if not (hum1 and hum1.Parent) then
  484.             hum1 = nil
  485.         end
  486.     end)
  487.  
  488.     ws.CurrentCamera.CameraSubject = hum1
  489.     local camSubCon = nil
  490.     local function camSubFunc()
  491.         camSubCon:Disconnect()
  492.         if c and hum1 then
  493.             ws.CurrentCamera.CameraSubject = hum1
  494.         end
  495.     end
  496.     camSubCon = renderstepped:Connect(camSubFunc)
  497.     if hum0 then
  498.         hum0:GetPropertyChangedSignal("Jump"):Connect(function()
  499.             if hum1 then
  500.                 hum1.Jump = hum0.Jump
  501.             end
  502.         end)
  503.     else
  504.         respawnrequest()
  505.     end
  506. end
  507.  
  508. local rb = Instance.new("BindableEvent", c)
  509. rb.Event:Connect(function()
  510.     pcall(destroy, rb)
  511.     sg:SetCore("ResetButtonCallback", true)
  512.     if destroyhum then
  513.         if c then c:BreakJoints() end
  514.         return
  515.     end
  516.     if model and hum0 and (hum0.Health > 0) then
  517.         model:BreakJoints()
  518.         hum0.Health = 0
  519.     end
  520.     if antirespawn then
  521.         respawnrequest()
  522.     end
  523. end)
  524. sg:SetCore("ResetButtonCallback", rb)
  525.  
  526. tdelay(0, function()
  527.     while c do
  528.         if hum0 and hum1 then
  529.             hum1.Jump = hum0.Jump
  530.         end
  531.         swait()
  532.     end
  533.     sg:SetCore("ResetButtonCallback", true)
  534. end)
  535.  
  536. R15toR6 = R15toR6 and hum1 and (hum1.RigType == Enum.HumanoidRigType.R15)
  537. if R15toR6 then
  538.     local part = gp(c, "HumanoidRootPart", "BasePart") or gp(c, "UpperTorso", "BasePart") or gp(c, "LowerTorso", "BasePart") or gp(c, "Head", "BasePart") or c:FindFirstChildWhichIsA("BasePart")
  539.     if part then
  540.         local cfr = part.CFrame
  541.         local R6parts = {
  542.             head = {
  543.                 Name = "Head",
  544.                 Size = v3(2, 1, 1),
  545.                 R15 = {
  546.                     Head = 0
  547.                 }
  548.             },
  549.             torso = {
  550.                 Name = "Torso",
  551.                 Size = v3(2, 2, 1),
  552.                 R15 = {
  553.                     UpperTorso = 0.2,
  554.                     LowerTorso = -0.8
  555.                 }
  556.             },
  557.             root = {
  558.                 Name = "HumanoidRootPart",
  559.                 Size = v3(2, 2, 1),
  560.                 R15 = {
  561.                     HumanoidRootPart = 0
  562.                 }
  563.             },
  564.             leftArm = {
  565.                 Name = "Left Arm",
  566.                 Size = v3(1, 2, 1),
  567.                 R15 = {
  568.                     LeftHand = -0.849,
  569.                     LeftLowerArm = -0.174,
  570.                     LeftUpperArm = 0.415
  571.                 }
  572.             },
  573.             rightArm = {
  574.                 Name = "Right Arm",
  575.                 Size = v3(1, 2, 1),
  576.                 R15 = {
  577.                     RightHand = -0.849,
  578.                     RightLowerArm = -0.174,
  579.                     RightUpperArm = 0.415
  580.                 }
  581.             },
  582.             leftLeg = {
  583.                 Name = "Left Leg",
  584.                 Size = v3(1, 2, 1),
  585.                 R15 = {
  586.                     LeftFoot = -0.85,
  587.                     LeftLowerLeg = -0.29,
  588.                     LeftUpperLeg = 0.49
  589.                 }
  590.             },
  591.             rightLeg = {
  592.                 Name = "Right Leg",
  593.                 Size = v3(1, 2, 1),
  594.                 R15 = {
  595.                     RightFoot = -0.85,
  596.                     RightLowerLeg = -0.29,
  597.                     RightUpperLeg = 0.49
  598.                 }
  599.             }
  600.         }
  601.         for i, v in pairs(c:GetChildren()) do
  602.             if v:IsA("BasePart") then
  603.                 for i1, v1 in pairs(c:GetChildren()) do
  604.                     if v1:IsA("Motor6D") then
  605.                         v1.Part0 = nil
  606.                     end
  607.                 end
  608.             end
  609.         end
  610.         part.Archivable = true
  611.         for i, v in pairs(R6parts) do
  612.             local part = part:Clone()
  613.             part:ClearAllChildren()
  614.             part.Name, part.Size, part.CFrame, part.Anchored, part.Transparency, part.CanCollide = v.Name, v.Size, cfr, false, 1, false
  615.             for i1, v1 in pairs(v.R15) do
  616.                 local R15part = gp(c, i1, "BasePart")
  617.                 local att = gp(R15part, "att1_" .. i1, "Attachment")
  618.                 if R15part then
  619.                     local weld = Instance.new("Weld")
  620.                     weld.Part0, weld.Part1, weld.C0, weld.C1, weld.Name = part, R15part, cf(0, v1, 0), cf_0, "Weld_" .. i1
  621.                     weld.Parent = R15part
  622.                     R15part.Massless, R15part.Name = true, "R15_" .. i1
  623.                     R15part.Parent = part
  624.                     if att then
  625.                         att.Position = v3(0, v1, 0)
  626.                         att.Parent = part
  627.                     end
  628.                 end
  629.             end
  630.             part.Parent = c
  631.             R6parts[i] = part
  632.         end
  633.         local R6joints = {
  634.             neck = {
  635.                 Parent = R6parts.torso,
  636.                 Name = "Neck",
  637.                 Part0 = R6parts.torso,
  638.                 Part1 = R6parts.head,
  639.                 C0 = cf(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0),
  640.                 C1 = cf(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  641.             },
  642.             rootJoint = {
  643.                 Parent = R6parts.root,
  644.                 Name = "RootJoint" ,
  645.                 Part0 = R6parts.root,
  646.                 Part1 = R6parts.torso,
  647.                 C0 = cf(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0),
  648.                 C1 = cf(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  649.             },
  650.             rightShoulder = {
  651.                 Parent = R6parts.torso,
  652.                 Name = "Right Shoulder",
  653.                 Part0 = R6parts.torso,
  654.                 Part1 = R6parts.rightArm,
  655.                 C0 = cf(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0),
  656.                 C1 = cf(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  657.             },
  658.             leftShoulder = {
  659.                 Parent = R6parts.torso,
  660.                 Name = "Left Shoulder",
  661.                 Part0 = R6parts.torso,
  662.                 Part1 = R6parts.leftArm,
  663.                 C0 = cf(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0),
  664.                 C1 = cf(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  665.             },
  666.             rightHip = {
  667.                 Parent = R6parts.torso,
  668.                 Name = "Right Hip",
  669.                 Part0 = R6parts.torso,
  670.                 Part1 = R6parts.rightLeg,
  671.                 C0 = cf(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0),
  672.                 C1 = cf(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  673.             },
  674.             leftHip = {
  675.                 Parent = R6parts.torso,
  676.                 Name = "Left Hip" ,
  677.                 Part0 = R6parts.torso,
  678.                 Part1 = R6parts.leftLeg,
  679.                 C0 = cf(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0),
  680.                 C1 = cf(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  681.             }
  682.         }
  683.         for i, v in pairs(R6joints) do
  684.             local joint = Instance.new("Motor6D")
  685.             for prop, val in pairs(v) do
  686.                 joint[prop] = val
  687.             end
  688.             R6joints[i] = joint
  689.         end
  690.         if hum1 then
  691.             hum1.RigType, hum1.HipHeight = Enum.HumanoidRigType.R6, 0
  692.         end
  693.     end
  694. end
  695.  
  696. local torso1 = torso
  697. torso = gp(c, "Torso", "BasePart") or ((not R15toR6) and gp(c, torso.Name, "BasePart"))
  698. if (typeof(hedafterneck) == "Instance") and head and torso and torso1 then
  699.     local conNeck, conTorso, conTorso1 = nil, nil, nil
  700.     local aligns = {}
  701.     local function enableAligns()
  702.         conNeck:Disconnect()
  703.         conTorso:Disconnect()
  704.         conTorso1:Disconnect()
  705.         for i, v in pairs(aligns) do
  706.             v.Enabled = true
  707.         end
  708.     end
  709.     conNeck = hedafterneck.Changed:Connect(function(prop)
  710.         if table.find({"Part0", "Part1", "Parent"}, prop) then
  711.             enableAligns()
  712.         end
  713.     end)
  714.     conTorso = torso:GetPropertyChangedSignal("Parent"):Connect(enableAligns)
  715.     conTorso1 = torso1:GetPropertyChangedSignal("Parent"):Connect(enableAligns)
  716.     for i, v in pairs(head:GetDescendants()) do
  717.         if v:IsA("AlignPosition") or v:IsA("AlignOrientation") then
  718.             i = tostring(i)
  719.             aligns[i] = v
  720.             v:GetPropertyChangedSignal("Parent"):Connect(function()
  721.                 aligns[i] = nil
  722.             end)
  723.             v.Enabled = false
  724.         end
  725.     end
  726. end
  727.  
  728. local flingpart0 = gp(model, flingpart, "BasePart") or gp(gp(model, flingpart, "Accessory"), "Handle", "BasePart")
  729. local flingpart1 = gp(c, flingpart, "BasePart") or gp(gp(c, flingpart, "Accessory"), "Handle", "BasePart")
  730.  
  731. local fling = function() end
  732. if flingpart0 and flingpart1 then
  733.     flingpart0:GetPropertyChangedSignal("Parent"):Connect(function()
  734.         if not (flingpart0 and flingpart0.Parent) then
  735.             flingpart0 = nil
  736.             fling = function() end
  737.         end
  738.     end)
  739.     flingpart0.Archivable = true
  740.     flingpart1:GetPropertyChangedSignal("Parent"):Connect(function()
  741.         if not (flingpart1 and flingpart1.Parent) then
  742.             flingpart1 = nil
  743.             fling = function() end
  744.         end
  745.     end)
  746.     local att0 = gp(flingpart0, "att0_" .. flingpart0.Name, "Attachment")
  747.     local att1 = gp(flingpart1, "att1_" .. flingpart1.Name, "Attachment")
  748.     if att0 and att1 then
  749.         att0:GetPropertyChangedSignal("Parent"):Connect(function()
  750.             if not (att0 and att0.Parent) then
  751.                 att0 = nil
  752.                 fling = function() end
  753.             end
  754.         end)
  755.         att1:GetPropertyChangedSignal("Parent"):Connect(function()
  756.             if not (att1 and att1.Parent) then
  757.                 att1 = nil
  758.                 fling = function() end
  759.             end
  760.         end)
  761.         local lastfling = nil
  762.         local mouse = lp:GetMouse()
  763.         fling = function(target, duration, rotVelocity)
  764.             if typeof(target) == "Instance" then
  765.                 if target:IsA("BasePart") then
  766.                     target = target.Position
  767.                 elseif target:IsA("Model") then
  768.                     target = gp(target, "HumanoidRootPart", "BasePart") or gp(target, "Torso", "BasePart") or gp(target, "UpperTorso", "BasePart") or target:FindFirstChildWhichIsA("BasePart")
  769.                     if target then
  770.                         target = target.Position
  771.                     else
  772.                         return
  773.                     end
  774.                 elseif target:IsA("Humanoid") then
  775.                     target = target.Parent
  776.                     if not (target and target:IsA("Model")) then
  777.                         return
  778.                     end
  779.                     target = gp(target, "HumanoidRootPart", "BasePart") or gp(target, "Torso", "BasePart") or gp(target, "UpperTorso", "BasePart") or target:FindFirstChildWhichIsA("BasePart")
  780.                     if target then
  781.                         target = target.Position
  782.                     else
  783.                         return
  784.                     end
  785.                 else
  786.                     return
  787.                 end
  788.             elseif typeof(target) == "CFrame" then
  789.                 target = target.Position
  790.             elseif typeof(target) ~= "Vector3" then
  791.                 target = mouse.Hit
  792.                 if target then
  793.                     target = target.Position
  794.                 else
  795.                     return
  796.                 end
  797.             end
  798.             if target.Y < ws.FallenPartsDestroyHeight + 5 then
  799.                 target = v3(target.X, ws.FallenPartsDestroyHeight + 5, target.Z)
  800.             end
  801.             lastfling = target
  802.             if type(duration) ~= "number" then
  803.                 duration = tonumber(duration) or 0.5
  804.             end
  805.             if typeof(rotVelocity) ~= "Vector3" then
  806.                 rotVelocity = v3(20000, 20000, 20000)
  807.             end
  808.             if not (target and flingpart0 and flingpart1 and att0 and att1) then
  809.                 return
  810.             end
  811.             flingpart0.Archivable = true
  812.             local flingpart = flingpart0:Clone()
  813.             flingpart.Transparency = 1
  814.             flingpart.CanCollide = false
  815.             flingpart.Name = "flingpart_" .. flingpart0.Name
  816.             flingpart.Anchored = true
  817.             flingpart.Velocity = v3_0
  818.             flingpart.RotVelocity = v3_0
  819.             flingpart.Position = target
  820.             flingpart:GetPropertyChangedSignal("Parent"):Connect(function()
  821.                 if not (flingpart and flingpart.Parent) then
  822.                     flingpart = nil
  823.                 end
  824.             end)
  825.             flingpart.Parent = flingpart1
  826.             if flingpart0.Transparency > 0.5 then
  827.                 flingpart0.Transparency = 0.5
  828.             end
  829.             att1.Parent = flingpart
  830.             local con = nil
  831.             local rotchg = v3(0, rotVelocity.Unit.Y * -1000, 0)
  832.             con = heartbeat:Connect(function(delta)
  833.                 if target and (lastfling == target) and flingpart and flingpart0 and flingpart1 and att0 and att1 then
  834.                     flingpart.Orientation += rotchg * delta
  835.                     flingpart0.RotVelocity = rotVelocity
  836.                 else
  837.                     con:Disconnect()
  838.                 end
  839.             end)
  840.             if alignmode ~= 4 then
  841.                 local con = nil
  842.                 con = renderstepped:Connect(function()
  843.                     if flingpart0 and target then
  844.                         flingpart0.RotVelocity = v3_0
  845.                     else
  846.                         con:Disconnect()
  847.                     end
  848.                 end)
  849.             end
  850.             twait(duration)
  851.             if lastfling ~= target then
  852.                 if flingpart then
  853.                     if att1 and (att1.Parent == flingpart) then
  854.                         att1.Parent = flingpart1
  855.                     end
  856.                     pcall(destroy, flingpart)
  857.                 end
  858.                 return
  859.             end
  860.             target = nil
  861.             if not (flingpart and flingpart0 and flingpart1 and att0 and att1) then
  862.                 return
  863.             end
  864.             flingpart0.RotVelocity = v3_0
  865.             att1.Parent = flingpart1
  866.             pcall(destroy, flingpart)
  867.         end
  868.     end
  869. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement