Guest User

Untitled

a guest
Apr 1st, 2015
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.04 KB | None | 0 0
  1. wait(1)
  2. local Players = game:GetService("Players")
  3. local LocalPlayer = Players.LocalPlayer
  4. local Character = LocalPlayer.Character
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6. local Characters = ReplicatedStorage.Characters
  7. local remote = ReplicatedStorage.CharacterPosition
  8. local Stepped = game:GetService("RunService").RenderStepped
  9. local HB = game:GetService("RunService").Stepped
  10.  
  11. local cf = CFrame.new
  12. local components = cf().components
  13. local inverse = cf().inverse
  14. local acos = math.acos
  15. local fromAxisAngle = CFrame.fromAxisAngle
  16. local v3 = Vector3.new
  17.  
  18. function AxisAngleInterpolate(c0,c1,t)--CFrame0,CFrame1,Tween
  19.  local _,_,_,xx,yx,zx,xy,yy,zy,xz,yz,zz=components(inverse(c0)*c1)
  20.  local r=acos((xx+yy+zz-1)/2)*t
  21.  local c=r==r and r~=0 and c0*fromAxisAngle(v3(yz-zy,zx-xz,xy-yx),r)+(c1.p-c0.p)*t or c0+(c1.p-c0.p)*t
  22.  if c.lookVector.x==c.lookVector.x then return c else return c0 end
  23. end
  24.  
  25. remote.OnClientEvent:connect(function(data)
  26.     for plr,positions in pairs (data) do
  27.         if plr == "Destroy these characters" then
  28.             for _,k in pairs (positions) do
  29.                 if k and k~=Character.Name then
  30.                     local player = Players:FindFirstChild(k)
  31.                     if player then
  32.                         local FakeCharacter = ReplicatedStorage.BasePlayer:Clone()
  33.                         local DidItWork = ypcall(function()
  34.                             k = Players[k].Character
  35.                             FakeCharacter.Parent = workspace
  36.                             FakeCharacter.Torso.roblox.Texture = k.Torso.roblox.Texture
  37.                             for _,l in pairs (k.Head:GetChildren()) do
  38.                                 l.Archivable = true
  39.                                 l:Clone().Parent = FakeCharacter.Head
  40.                             end
  41.                             for _,j in pairs(k:GetChildren()) do
  42.                                 if j:isA("CharacterMesh") then
  43.                                     j:Clone().Parent = FakeCharacter
  44.                                 elseif j:IsA("Hat") then
  45.                                     local hat = j.Handle:Clone()
  46.                                     hat.Name = j.Name
  47.                                     hat.Parent = FakeCharacter
  48.                                     hat.Anchored = true
  49.                                 elseif j:IsA("BodyColors") or j:IsA("Shirt") or j:IsA("Pants") then
  50.                                     j:Clone().Parent = FakeCharacter
  51.                                 end
  52.                             end
  53.                             for _,h in pairs (k:GetChildren()) do
  54.                                 if h.Name == "Head" then
  55.                                     h.CanCollide = false
  56.                                     h.Transparency = 1
  57.                                     h.face.Transparency = 1
  58.                                 else
  59.                                     h:Destroy()
  60.                                 end
  61.                             end
  62.                             FakeCharacter.Parent = k
  63.                             wait()
  64.                             k.Head.CanCollide = false
  65.                             for _,h in pairs (FakeCharacter:GetChildren()) do
  66.                                 h.Name = h.Name.."Part"
  67.                                 if h:IsA("BasePart") then
  68.                                     h.CanCollide = false
  69.                                 end
  70.                             end
  71.                         end)
  72.                         if not DidItWork then
  73.                             FakeCharacter:Destroy()
  74.                         end
  75.                     end
  76.                 end
  77.             end
  78.             break
  79.         end
  80.         local plrCharacter = Players[plr].Character
  81.         if plrCharacter and plrCharacter:FindFirstChild("BasePlayer") then
  82.             local dp = {}
  83.             local LastCF = {}
  84.             local StartCF = {}
  85.             local cParts = plrCharacter.BasePlayer:GetChildren()
  86.             for i = 1, #cParts do
  87.                 if cParts[i]:isA("BasePart") then
  88.                     LastCF[cParts[i].Name]=cParts[i].CFrame
  89.                     StartCF[cParts[i].Name]=cParts[i].CFrame
  90.                 end
  91.             end
  92.             for i = 1, 3 do
  93.                 for m,k in pairs (positions) do
  94.                     local pName = m.."Part"
  95.                     dp[pName]=true
  96.                     if plrCharacter.BasePlayer:FindFirstChild(pName) then
  97.                         if plrCharacter.BasePlayer[pName].CFrame == LastCF[pName] then
  98.                             plrCharacter.BasePlayer[pName].CFrame = AxisAngleInterpolate(StartCF[pName],k,i/3)
  99.                         end
  100.                     end
  101.                 end
  102.                 Stepped:wait()
  103.             end
  104.         end
  105.     end
  106. end)
  107. local Removed = {}
  108. Character.ChildRemoved:connect(function(it)
  109.     if it.ClassName == "Part" or it.ClassName == "Hat" then
  110.         table.insert(Removed,it.Name)
  111.     end
  112. end)
  113. repeat
  114.     local parts = Character:GetChildren()
  115.     local Positions = {}
  116.     for i = 1, #parts do
  117.         if parts[i].ClassName == "Part" then
  118.             Positions[parts[i].Name]=parts[i].CFrame
  119.         elseif parts[i].ClassName == "Hat" then
  120.             Positions[parts[i].Name]=parts[i].Handle.CFrame
  121.         end
  122.     end
  123.     if #Removed > 0 then
  124.         for i = 1, #Removed do
  125.             Positions[Removed[i]]=CFrame.new(0,-20,0)
  126.         end
  127.         Removed = {}
  128.     end
  129.     remote:FireServer(Positions)
  130.     HB:wait()
  131. until Character.Humanoid.Health==0
Add Comment
Please, Sign In to add comment