View difference between Paste ID: G15uuN15 and 6SD0T4sp
SHOW: | | - or go back to the newest paste.
1
wait()
2-
Services = setmetatable({},{__index=function(s,r) return game:service(r) end})
2+
3-
Player = Services.Players.LocalPlayer
3+
script.Parent=nil
4
BodyParts={}
5
abs = function(int)
6-
wait()script.Parent=nil
6+
7
end
8
rad = function(deg)
9
	return deg * math.pi / 180
10
end
11
deg = function(rad)
12
	return rad * 180 / math.pi
13
end
14
dist = function(p1,p2)
15
	r,e = ypcall(function()
16
		p1 = p1.Position
17
	end)
18
	if not r then p1 = p1 end
19
	r,e = ypcall(function()
20
		p2 = p2.Position
21
	end)
22
	if not r then p1 = p1 end
23
	return math.sqrt( (p2.X-p1.X)^2 + (p2.Y-p1.Y)^2 + (p2.Z-p1.Z)^2 ) 
24
end
25
26
27
28
29
30
function GetHum()
31
	for i,v in pairs(GetChar():children'') do
32
		if v.ClassName == 'Humanoid' then
33
			return v
34
		end
35
	end
36
end
37
38
function GetChar()
39
	return Player.Character
40
end
41
42
function Died()
43
	for i,v in pairs(GetChar():children'') do
44
		if v.ClassName == 'Part' then
45
			table.insert(BodyParts,{v.CFrame,v})
46
		elseif v.ClassName == 'Hat' then
47
			v.Parent=workspace
48
			table.insert(BodyParts,{v.Handle.CFrame,v.Handle,1})
49
		end
50
	end
51
	
52
	wait(3)
53
	for i,v in pairs(BodyParts) do 
54
		v[2].Anchored=true 
55
		if v[2].Name == 'Torso' then pos = v[1] end
56
	end
57
	
58
	for i,v in pairs(BodyParts) do
59
		coroutine.resume(coroutine.create(function()
60
			repeat Services.RunService.Heartbeat:wait()
61
				v[2].CFrame = v[2].CFrame:lerp(v[1],.1)
62
			until dist(v[2],v[1]) < .05
63
			v[2].CFrame=v[1]
64
		end))
65
	end
66
end
67
68
Player.CharacterAdded:connect(function(char)
69
	char:WaitForChild('Torso')
70
	for i,v in pairs(BodyParts) do
71
		if v[3] then
72
			v[2]:Remove()
73
		end
74
	end
75
	BodyParts={}
76
	char.Torso.CFrame=pos or CFrame.new(0,12,0)
77
	GetHum().Died:connect(Died)
78
end)
79
GetHum().Died:connect(Died)
80
print'rannering'