Advertisement
Godofadmin1337

body swap potion

Sep 27th, 2017
1,847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Script3 = Instance.new("Script")
  23. LocalScript4 = Instance.new("LocalScript")
  24. Animation5 = Instance.new("Animation")
  25. ObjectValue6 = Instance.new("ObjectValue")
  26. RemoteEvent7 = Instance.new("RemoteEvent")
  27. LocalScript8 = Instance.new("LocalScript")
  28. Tool0.Name = "FreakyFridayPotion"
  29. Tool0.Parent = mas
  30. Tool0.TextureId = "http://www.roblox.com/asset/?id=78673347"
  31. Tool0.GripForward = Vector3.new(-0, 1, -0)
  32. Tool0.GripPos = Vector3.new(0.150000006, -0.150000006, -0.5)
  33. Tool0.GripUp = Vector3.new(0, 0, 1)
  34. Part1.Name = "Handle"
  35. Part1.Parent = Tool0
  36. Part1.BrickColor = BrickColor.new("Bright bluish green")
  37. Part1.Rotation = Vector3.new(-90, 0, 0)
  38. Part1.FormFactor = Enum.FormFactor.Custom
  39. Part1.Size = Vector3.new(0.659999907, 0.80000025, 1.62999988)
  40. Part1.CFrame = CFrame.new(21.4099903, 0.814999938, -15.7599859, 1, 0, 0, 0, 0, 1, 0, -1, 0)
  41. Part1.Color = Color3.new(0, 0.560784, 0.611765)
  42. Part1.Position = Vector3.new(21.4099903, 0.814999938, -15.7599859)
  43. Part1.Orientation = Vector3.new(-90, 0, 0)
  44. Part1.Color = Color3.new(0, 0.560784, 0.611765)
  45. SpecialMesh2.Parent = Part1
  46. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=78673311"
  47. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=78673334"
  48. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  49. Script3.Parent = Tool0
  50. table.insert(cors,sandbox(Script3,function()
  51. local Tool = script.Parent
  52. local Players = game:GetService'Players'
  53.  
  54. SwitchClothes = {
  55. Accoutrement = function(char, hat)
  56. local handle = hat:FindFirstChild'Handle'
  57. local head = char:FindFirstChild'Head'
  58.  
  59. handle:BreakJoints()
  60.  
  61. if handle and handle:IsA'BasePart' and head and head:IsA'BasePart' then
  62. hat.Parent = nil
  63. local hatWeld = Instance.new'Weld'
  64. hatWeld.Part0 = head
  65. hatWeld.Part1 = handle
  66. hatWeld.C1 = head.CFrame * hat.AttachmentPoint:inverse() * CFrame.new(0, 0.5, -9.53674316e-007, 1, -1.89326617e-029, 0, -1.89326617e-029, 1, 2.5243549e-029, 0, 2.5243549e-029, 1)
  67. hatWeld.Name = 'HeadWeld'
  68. hatWeld.Parent = head
  69. hat.Parent = char
  70. end
  71. end,
  72. CharacterAppearance = function(char, appItem)
  73. appItem.Parent = char
  74. end,
  75. DataModelMesh = function(char, appItem)
  76. appItem.Parent = char:FindFirstChild'Head'
  77. end,
  78. FaceInstance = function(char, appItem)
  79. appItem.Parent = char:FindFirstChild'Head'
  80. end
  81. }
  82.  
  83. function animate(char)
  84. local animateScript = script.AnimateCharacterScript:Clone()
  85. for i, obj in next, char:GetChildren() do
  86. if obj:IsA'Humanoid' or obj:IsA'AnimationController' then
  87. animateScript.Humanoid.Value = obj
  88. break
  89. end
  90. end
  91.  
  92. animateScript.Parent = char
  93. animateScript.Disabled = false
  94. end
  95.  
  96. Tool.SwapWith.OnServerEvent:connect(function(client, character)
  97. if client == Players:GetPlayerFromCharacter(Tool.Parent) and client.Character then
  98. local otherPlayer = Players:GetPlayerFromCharacter(character)
  99. if not otherPlayer then return end -- Remove to make it work with NPCs
  100.  
  101. local clothesA, clothesB = {}, {}
  102. for i, child in next, client.Character:GetChildren() do
  103. local use = false
  104. for className in next, SwitchClothes do
  105. if child:IsA(className) then
  106. use = true
  107. break
  108. end
  109. end
  110.  
  111. if use then
  112. table.insert(clothesA, child)
  113. end
  114. end
  115. for i, obj in next, client.Character:FindFirstChild'Head' and client.Character.Head:GetChildren() do
  116. if obj:IsA'DataModelMesh' or obj:IsA'FaceInstance' then
  117. table.insert(clothesA, obj)
  118. end
  119. end
  120. for i, child in next, character:GetChildren() do
  121. local use = false
  122. for className in next, SwitchClothes do
  123. if child:IsA(className) then
  124. use = true
  125. break
  126. end
  127. end
  128.  
  129. if use then
  130. table.insert(clothesB, child)
  131. end
  132. end
  133. for i, obj in next, character:FindFirstChild'Head' and character.Head:GetChildren() do
  134. if obj:IsA'DataModelMesh' or obj:IsA'FaceInstance' then
  135. table.insert(clothesB, obj)
  136. end
  137. end
  138. for i, item in next, clothesA do
  139. for className, f in next, SwitchClothes do
  140. if item:IsA(className) then print(item:GetFullName(),'is',className)
  141. f(character, item)
  142. print(item:GetFullName(),'moved')
  143. break
  144. end
  145. end
  146. end
  147. for i, item in next, clothesB do
  148. for className, f in next, SwitchClothes do
  149. if item:IsA(className) then
  150. f(client.Character, item)
  151. break
  152. end
  153. end
  154. end
  155.  
  156. if otherPlayer then
  157. animate(character)
  158. end
  159. animate(client.Character)
  160.  
  161. if otherPlayer and client.Character:FindFirstChild'HumanoidRootPart' and character:FindFirstChild'HumanoidRootPart' and client.Character.HumanoidRootPart.Anchored == false and character.HumanoidRootPart.Anchored == false then
  162. local posA, posB = client.Character.HumanoidRootPart.CFrame, character.HumanoidRootPart.CFrame
  163. client.Character.HumanoidRootPart.CFrame = posB
  164. character.HumanoidRootPart.CFrame = posA
  165. end
  166. end
  167. end)
  168. end))
  169. LocalScript4.Name = "AnimateCharacterScript"
  170. LocalScript4.Parent = Script3
  171. LocalScript4.Disabled = true
  172. table.insert(cors,sandbox(LocalScript4,function()
  173. local track = (script:WaitForChild'Humanoid'.Value or script.Humanoid.Changed:wait()):LoadAnimation(script.SwapAnim)
  174. track:Play()
  175.  
  176. wait(1)
  177. script:Destroy()
  178. end))
  179. Animation5.Name = "SwapAnim"
  180. Animation5.Parent = LocalScript4
  181. Animation5.AnimationId = "http://www.roblox.com/Asset?ID=78674033"
  182. ObjectValue6.Name = "Humanoid"
  183. ObjectValue6.Parent = LocalScript4
  184. RemoteEvent7.Name = "SwapWith"
  185. RemoteEvent7.Parent = Tool0
  186. LocalScript8.Parent = Tool0
  187. table.insert(cors,sandbox(LocalScript8,function()
  188. local Tool = script.Parent
  189. Tool.Enabled = true
  190. local Players = game:GetService'Players'
  191.  
  192. GetCharacterFromPart = function(part)
  193. local current = part
  194. local character = nil
  195. while true do
  196. for i, child in next, current:GetChildren() do
  197. if child:IsA'Humanoid' then
  198. character = current
  199. break
  200. end
  201. end
  202.  
  203. if character then
  204. break
  205. else
  206. current = current.Parent
  207.  
  208. if not current or current == game then
  209. break
  210. end
  211. end
  212. end
  213.  
  214. return character, character and Players:GetPlayerFromCharacter(character)
  215. end
  216.  
  217. Tool.Equipped:connect(function(mouse)
  218. mouse.Icon = 'rbxasset://textures/GunCursor.png'
  219.  
  220. mouse.Button1Down:connect(function()
  221. local hit = mouse.Target
  222. local char = GetCharacterFromPart(hit)
  223.  
  224. if char then
  225. Tool.SwapWith:FireServer(char)
  226.  
  227. mouse.Icon = 'rbxasset://textures/GunWaitCursor.png'
  228. Tool.Enabled = false
  229. wait(2)
  230. mouse.Icon = 'rbxasset://textures/GunCursor.png'
  231. Tool.Enabled = true
  232. end
  233. end)
  234. end)
  235. end))
  236. for i,v in pairs(mas:GetChildren()) do
  237. v.Parent = workspace
  238. pcall(function() v:MakeJoints() end)
  239. end
  240. mas:Destroy()
  241. for i,v in pairs(cors) do
  242. spawn(function()
  243. pcall(v)
  244. end)
  245. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement