ttvmetroidd

light warp attack

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