Advertisement
HenloMyDude

my own ghost (unfinished) (can noclip)

Feb 29th, 2020
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. plr = owner
  2. char = plr.Character
  3. root = char.HumanoidRootPart
  4.  
  5. Swait,swait = function(number)
  6. if number == 0 or number == nil then
  7. game:GetService("RunService").Heartbeat:Wait()
  8. else
  9. for i = 1,number do
  10. game:GetService("RunService").Heartbeat:Wait()
  11. end
  12. end
  13. end
  14.  
  15. ezweld = function(p, a, b, cf)
  16. local weld = Instance.new("Weld",p)
  17. weld.Part0 = a
  18. weld.Part1 = b
  19. weld.C0 = cf
  20. return weld
  21. end
  22.  
  23. NewSound = function(p, id, pit, vol, loop)
  24. local Sound = Instance.new("Sound",p)
  25. Sound.Pitch = pit
  26. Sound.Volume = vol
  27. Sound.SoundId = "rbxassetid://" ..id
  28. Sound.Looped = loop
  29. Sound:Play()
  30. return Sound
  31. end
  32.  
  33. function fake(part, hide, join, p)
  34. local fake = Instance.new("Part", p)
  35. fake.Size = part.Size
  36. fake.Color = part.Color
  37. fake.Anchored = part.Anchored
  38. fake.CFrame = part.CFrame
  39. fake.CanCollide = part.CanCollide
  40. --fake.LeftSurface = part.LeftSurface
  41. --fake.RightSurface = part.RightSurface
  42. --fake.TopSurface = part.TopSurface
  43. --fake.BottomSurface = part.BottomSurface
  44. --fake.FrontSurface = part.FrontSurface
  45. --fake.BackSurface = part.BackSurface
  46. for i,v in pairs (part:children()) do
  47. if v:IsA("SpecialMesh") then
  48. v:Clone().Parent = fake
  49. end
  50. end
  51. if join == true then
  52. local weld = ezweld(part.Parent, fake, part, CFrame.new())
  53. end
  54. if hide == true then
  55. part.Transparency = 1
  56. end
  57. return fake
  58. end
  59.  
  60. local model = Instance.new("Model", script)
  61. model.Name = plr.Name .."ghost"
  62. stopi = false
  63.  
  64. plr.Chatted:connect(function(msg)
  65. if msg:sub(1, 5) == "/stop" then
  66. stopi = true
  67. for i,v in pairs (workspace:children()) do
  68. if v:IsA("Model") and v.Name == plr.Name .."ghost" then
  69. v:Destroy()
  70. end
  71. end
  72. script.Disabled = true
  73. end
  74. end)
  75.  
  76. for i,v in pairs (char:children()) do
  77. if v:IsA("Part") and v ~= root then
  78. local E = fake(v, false, false, model)
  79. E.Name = v.Name
  80. E.Anchored = true
  81. end
  82. end
  83.  
  84. rootj = root.RootJoint
  85. rootjnor = rootj.C0
  86.  
  87. rootj.C0 = rootjnor * CFrame.new(0, 0, -875)
  88.  
  89.  
  90. for i,v in pairs (char:GetDescendants()) do
  91. if v:IsA("Hat") or v:IsA("Accessory") or v:IsA("Decal") or v:IsA("Texture") then
  92. v:remove()
  93. end
  94. if v:IsA("Part") then
  95. local mesh = Instance.new("SpecialMesh",v)
  96. mesh.Scale = Vector3.new(0, 0, 0)
  97. v.Transparency = 1
  98. end
  99. end
  100.  
  101. function refit()
  102. model:remove()
  103. local rcf = root.CFrame
  104. plr:LoadCharacter()
  105. plr = plr
  106. mud = plr.Character
  107. char = mud
  108. char = mud
  109. root = char:WaitForChild("HumanoidRootPart")
  110. root.CFrame = rcf
  111.  
  112. local model = Instance.new("Model", script)
  113. model.Name = plr.Name .."ghost"
  114.  
  115. Instance.new("NumberValue", char).Name = "refitted"
  116.  
  117. for i,v in pairs (char:children()) do
  118. if v:IsA("Part") and v ~= root then
  119. local E = fake(v, false, false, model)
  120. E.Name = v.Name
  121. E.Anchored = true
  122. end
  123. end
  124.  
  125. rootj = root.RootJoint
  126. rootjnor = rootj.C0
  127.  
  128. rootj.C0 = rootjnor * CFrame.new(0, 0, -875)
  129.  
  130.  
  131. for i,v in pairs (char:GetDescendants()) do
  132. if v:IsA("Hat") or v:IsA("Accessory") or v:IsA("Decal") or v:IsA("Texture") then
  133. v:remove()
  134. end
  135. if v:IsA("Part") then
  136. local mesh = Instance.new("SpecialMesh",v)
  137. mesh.Scale = Vector3.new(0, 0, 0)
  138. v.Transparency = 1
  139. end
  140. end
  141.  
  142. char.Humanoid.Died:connect(refit)
  143.  
  144. coroutine.resume(coroutine.create(function()
  145.  
  146. while true do
  147. Swait()
  148. char = mud
  149. root = char.HumanoidRootPart
  150. if root and char then
  151. root.Anchored = false
  152. for i,v in pairs (model:children()) do
  153. if v:IsA("Part") then
  154. v.Parent = model
  155. v.CanCollide = false
  156. v.Transparency = 0.5
  157. v.Material = "Glass"
  158. v.Locked = true
  159. if v.Name == "Head" then
  160. v.Size = Vector3.new(1, 1, 1)
  161. v:ClearAllChildren()
  162. end
  163. local match = char:FindFirstChild(v.Name)
  164. if match ~= nil then
  165. v.Size = match.Size
  166. if v.Name == "Head" then
  167. v.Size = Vector3.new(v.Size.x/2, v.Size.y, v.Size.z)
  168. end
  169. v.CFrame = match.CFrame
  170. v.Position = v.Position + Vector3.new(0, 875, 0)
  171. end
  172. end
  173. end
  174. end
  175. end
  176.  
  177. end))
  178.  
  179. end
  180.  
  181. char.Humanoid.Died:connect(refit)
  182.  
  183. coroutine.resume(coroutine.create(function()
  184.  
  185. while true do
  186. Swait()
  187. char = plr.Character
  188. root = char.HumanoidRootPart
  189. if root and char then
  190. root.Anchored = false
  191. for i,v in pairs (model:children()) do
  192. if v:IsA("Part") then
  193. v.Parent = model
  194. v.CanCollide = false
  195. v.Transparency = 0.5
  196. v.Material = "Glass"
  197. v.Locked = true
  198. if v.Name == "Head" then
  199. v.Size = Vector3.new(1, 1, 1)
  200. v:ClearAllChildren()
  201. end
  202. local match = char:FindFirstChild(v.Name)
  203. if match ~= nil then
  204. v.Size = match.Size
  205. if v.Name == "Head" then
  206. v.Size = Vector3.new(v.Size.x/2, v.Size.y, v.Size.z)
  207. end
  208. v.CFrame = match.CFrame
  209. v.Position = v.Position + Vector3.new(0, 875, 0)
  210. end
  211. end
  212. end
  213. end
  214. end
  215.  
  216. end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement