ttvmetroidd

Untitled

Jun 19th, 2024
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. --Cool Sword of Light transport process
  2.  
  3. local Properties = {
  4. TravelTime = 1,
  5. OrbSpread = 25
  6. }
  7.  
  8. function Create(ty)
  9. return function(data)
  10. local obj = Instance.new(ty)
  11. for k, v in pairs(data) do
  12. if type(k) == 'number' then
  13. v.Parent = obj
  14. else
  15. obj[k] = v
  16. end
  17. end
  18. return obj
  19. end
  20. end
  21.  
  22. local Character = script:WaitForChild("Character").Value
  23.  
  24. local Humanoid = Character:FindFirstChildOfClass("Humanoid")
  25.  
  26. local Center = Character:WaitForChild("HumanoidRootPart")
  27.  
  28. local LightEffects = script:WaitForChild("LightEffects"):GetChildren()
  29.  
  30. local TargetLocation,Range = script:WaitForChild("TargetLocation"),script:WaitForChild("Range") --Assumes this is present
  31.  
  32. local Bezier = script:WaitForChild("BezierCurves")
  33.  
  34. if not TargetLocation or not Range or not Bezier or not Center then script:Destroy() end
  35.  
  36. Range = Range.Value
  37.  
  38. TargetLocation = Center.Position + ((TargetLocation.Value + Vector3.new(0,3,0)) - Center.Position).Unit * math.clamp(((TargetLocation.Value + Vector3.new(0,3,0)) - Center.Position).Magnitude,0,Range)
  39.  
  40. local Services = {
  41. Players = (game:FindService("Players") or game:GetService("Players")),
  42. RunService = (game:FindService("RunService") or game:GetService("RunService")),
  43. Debris = (game:FindService("Debris") or game:GetService("Debris")),
  44. Lighting = (game:FindService("Lighting") or game:GetService("Lighting")),
  45. ServerScriptService = (game:FindService("ServerScriptService") or game:GetService("ServerScriptService")),
  46. ServerStorage = (game:FindService("ServerStorage") or game:GetService("ServerStorage"))
  47. }
  48.  
  49. Bezier = require(Bezier)
  50.  
  51. local Seed = Random.new()
  52.  
  53. local LightBall = Create("Part"){
  54. Lod = true,
  55. Anchored = true,
  56. CanCollide = false,
  57. Shape = Enum.PartType.Ball,
  58. Name = "Light Orb",
  59. Size = Vector3.new(1,1,1) * Seed:NextNumber(2,3),
  60. Material = Enum.Material.Neon,
  61. Color = Color3.fromRGB(255,255,203),
  62. TopSurface = Enum.SurfaceType.Smooth,
  63. BottomSurface = Enum.SurfaceType.Smooth
  64. }
  65.  
  66. local AttachmentA = Create("Attachment"){
  67. Position = Vector3.new(0,LightBall.Size.Y/2,0),
  68. Name = "AttachmentA",
  69. Parent = LightBall
  70. }
  71.  
  72. local AttachmentB = AttachmentA:Clone()
  73. AttachmentB.Name = "AttachmentB"
  74. AttachmentB.Position = Vector3.new(0,-LightBall.Size.Y/2,0)
  75. AttachmentB.Parent = AttachmentA.Parent
  76.  
  77. for i=1,#LightEffects do
  78. LightEffects[i].Parent = LightBall
  79. LightEffects[i].Enabled = true
  80. if LightEffects[i]:IsA("Trail") then
  81. LightEffects[i].Attachment0 = AttachmentA
  82. LightEffects[i].Attachment1 = AttachmentB
  83. end
  84. end
  85.  
  86. --Begin Teleport process
  87.  
  88. --Make the character temporarily invisible & Invincible
  89. --Make Player Camera follow one of the orbs
  90. --(Possibly) Create sparkles splash effect
  91. --Spawn the Character at the targeted destination
  92.  
  93. local Light_Segments = 10
  94.  
  95. local LightBallAnimations = {}
  96.  
  97. local TrackOrb,FixCam = script:WaitForChild("TrackOrb"),script:WaitForChild("FixCam")
  98.  
  99. local AffectedParts = {}
  100. local Parts = Character:GetDescendants()
  101. for i=1,#Parts do
  102. if Parts[i]:IsA("BasePart") then
  103. AffectedParts[#AffectedParts+1] = {Part = Parts[i], Transparency = Parts[i].Transparency,CanCollide = Parts[i].CanCollide,Anchored = Parts[i].Anchored}
  104. Parts[i].CanCollide = false
  105. Parts[i].Transparency = 1
  106. Parts[i].Anchored = true
  107. end
  108. end
  109.  
  110. local ForceFieldExists = Character:FindFirstChildOfClass("ForceField")
  111. local ForceField
  112.  
  113. if ForceFieldExists then
  114. ForceFieldExists.Visible = false
  115. end
  116.  
  117. if not ForceFieldExists then -- give invincibility when travelling
  118. ForceField = Create("ForceField"){
  119. Name = "Invincibility",
  120. Visible = false,
  121. Parent = Character
  122. }
  123. end
  124.  
  125. local HeldTool = Character:FindFirstChildOfClass("Tool")
  126. if HeldTool then
  127. Humanoid:UnequipTools()
  128. end
  129.  
  130. --Character.Parent = Services.ServerStorage
  131.  
  132. for Angle = 0, 360,(360/(Light_Segments-1)) do --Create LightBall
  133. local LightClone = LightBall:Clone()
  134. LightClone.CFrame = (Center.CFrame * CFrame.Angles(math.rad(90),math.rad(Angle),0)) * CFrame.new(0,0,1)
  135. LightBallAnimations[#LightBallAnimations+1] = {Start = Center.CFrame, Control = Center.CFrame:lerp((CFrame.new(TargetLocation)*(Center.CFrame-Center.CFrame.p)),.5)*CFrame.new(Seed:NextNumber(-Properties.OrbSpread,Properties.OrbSpread),Seed:NextNumber(-Properties.OrbSpread,Properties.OrbSpread),Seed:NextNumber(-Properties.OrbSpread,Properties.OrbSpread)), End = CFrame.new(TargetLocation)*(Center.CFrame-Center.CFrame.p), Object = LightClone}
  136. LightClone.Parent = workspace
  137. end
  138.  
  139. local TrackedOrb = Create("ObjectValue"){
  140. Name = "TrackedOrb",
  141. Value = LightBallAnimations[1].Object,
  142. Parent = TrackOrb
  143. }
  144.  
  145. --local DisableBackpack = script:WaitForChild("DisableBackpack")
  146. if Services.Players:GetPlayerFromCharacter(Character) and Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui") then
  147. TrackOrb.Parent = Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui")
  148. TrackOrb.Disabled = false
  149.  
  150. --DisableBackpack.Parent = Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui")
  151. --DisableBackpack.Disabled = false
  152. end
  153.  
  154. local UnequipLoop
  155.  
  156. UnequipLoop = Character.ChildAdded:Connect(function(child)
  157. if child:IsA("Tool") and Services.Players:GetPlayerFromCharacter(Character) and Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("Backpack") then
  158. --Humanoid:UnequipTools()
  159. Services.RunService.Stepped:Wait() --Wait at least 1 frame or that warning will occur
  160. child.Parent = Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("Backpack")
  161. end
  162. end)
  163.  
  164. local floor = math.floor
  165. for i=0,floor(60*(Properties.TravelTime)),1 do
  166. local Precentage = (i/(60*Properties.TravelTime))*100
  167. for t=1,#LightBallAnimations,1 do
  168. Bezier.Quadratic(Precentage,LightBallAnimations[t].Start,LightBallAnimations[t].Control,LightBallAnimations[t].End,LightBallAnimations[t].Object,"CFrame")
  169. end
  170. Services.RunService.Heartbeat:Wait()
  171. end
  172.  
  173. for t=1,#LightBallAnimations,1 do
  174. if LightBallAnimations[t].Object then
  175. if LightBallAnimations[t].Object:FindFirstChildOfClass("ParticleEmitter") then
  176. LightBallAnimations[t].Object:FindFirstChildOfClass("ParticleEmitter").Enabled = false
  177. end
  178. LightBallAnimations[t].Object.Size = Vector3.new(1,1,1)*0
  179. LightBallAnimations[t].Object.Transparency = 1
  180. Services.Debris:AddItem(LightBallAnimations[t].Object,2)
  181. end
  182. end
  183.  
  184. --[[local EnableBackpack = script:WaitForChild("EnableBackpack")
  185. if Services.Players:GetPlayerFromCharacter(Character) and Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui") then
  186. EnableBackpack.Parent = Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui")
  187. EnableBackpack.Disabled = false
  188. Services.Debris:AddItem(EnableBackpack,1)
  189. end]]
  190.  
  191. if UnequipLoop then UnequipLoop:Disconnect();UnequipLoop = nil end
  192.  
  193. if Humanoid then
  194. Humanoid.Health = Humanoid.Health + 15
  195. end
  196.  
  197. Character:SetPrimaryPartCFrame(CFrame.new(TargetLocation)*(Center.CFrame-Center.CFrame.p))
  198.  
  199. for i=1,#AffectedParts do
  200. for property, value in pairs(AffectedParts[i]) do
  201. if property ~= "Part" then
  202. AffectedParts[i].Part[property] = value
  203. end
  204. end
  205. end
  206.  
  207. if ForceField then
  208. ForceField:Destroy()
  209. end
  210.  
  211. if HeldTool then
  212. Humanoid:EquipTool(HeldTool)
  213. end
  214.  
  215. if Services.Players:GetPlayerFromCharacter(Character) and Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui") then
  216. FixCam.Parent = Services.Players:GetPlayerFromCharacter(Character):FindFirstChild("PlayerGui")
  217. FixCam.Disabled = false
  218. end
  219.  
  220. --DisableBackpack:Destroy()
  221. Services.Debris:AddItem(TrackOrb,1)
  222. Services.Debris:AddItem(FixCam,2)
  223. script:Destroy()
  224.  
Advertisement
Add Comment
Please, Sign In to add comment