ttvmetroidd

sword

Jun 20th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.92 KB | None | 0 0
  1. --Rescripted by TakeoHonorable
  2. --Sword of Light Revamped
  3.  
  4. function Create(ty)
  5. return function(data)
  6. local obj = Instance.new(ty)
  7. for k, v in pairs(data) do
  8. if type(k) == 'number' then
  9. v.Parent = obj
  10. else
  11. obj[k] = v
  12. end
  13. end
  14. return obj
  15. end
  16. end
  17.  
  18. local Services = {
  19. Players = (game:FindService("Players") or game:GetService("Players")),
  20. TweenService = (game:FindService("TweenService") or game:GetService("TweenService")),
  21. RunService = (game:FindService("RunService") or game:GetService("RunService")),
  22. Debris = (game:FindService("Debris") or game:GetService("Debris")),
  23. ReplicatedStorage = (game:FindService("ReplicatedStorage") or game:GetService("ReplicatedStorage")),
  24. Lighting = (game:FindService("Lighting") or game:GetService("Lighting")),
  25. ServerScriptService = (game:FindService("ServerScriptService") or game:GetService("ServerScriptService"))
  26. }
  27.  
  28. local Tool = script.Parent
  29. Tool.Enabled = true
  30.  
  31. local Handle = Tool:WaitForChild("Handle")
  32.  
  33. --[[local SwordMesh = Handle:WaitForChild("SwordMesh")
  34. SwordMesh.VertexColor = Vector3.new(1,1,1) -- Keep it normal]]
  35.  
  36. local Properties = {
  37. Damage = 3,
  38. Special = true,
  39. SpecialReload = 30,
  40. SpecialActive = false,
  41. TimetoChange = 12,
  42. LightTeleport = true
  43. }
  44.  
  45. local Sounds = {
  46. Lunge = Handle:WaitForChild("Lunge"),
  47. Unsheath = Handle:WaitForChild("Unsheath")
  48. }
  49.  
  50. local Remote = Tool:FindFirstChildOfClass("RemoteEvent") or Create("RemoteEvent"){
  51. Name = "Remote",
  52. Parent = Tool
  53. }
  54.  
  55. local MousePos = Tool:FindFirstChildOfClass("RemoteFunction") or Create("RemoteFunction"){
  56. Name = "MouseInput",
  57. Parent = Tool
  58. }
  59.  
  60. local function SunIsVisible(Character)
  61. local dir = Services.Lighting:GetSunDirection()
  62. if Vector3.new(0,1,0):Dot(dir) > 0 then
  63. -- BUG: particles block raycast
  64. local hit = workspace:FindPartOnRay(Ray.new(Handle.Position,dir*999),Character)
  65. if not hit or (hit and not hit.CanCollide)then
  66. return true
  67. end
  68. end
  69. return false
  70. end
  71.  
  72. function IsInTable(Table,Value)
  73. for _,v in pairs(Table) do
  74. if v == Value then
  75. return true
  76. end
  77. end
  78. return false
  79. end
  80.  
  81. local function Wait(para) -- bypasses the latency
  82. local Initial = tick()
  83. repeat
  84. Services.RunService.Stepped:Wait()
  85. until tick()-Initial >= para
  86. end
  87.  
  88. function IsTeamMate(Player1, Player2)
  89. return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
  90. end
  91.  
  92. function TagHumanoid(humanoid, player)
  93. local Creator_Tag = Instance.new("ObjectValue")
  94. Creator_Tag.Name = "creator"
  95. Creator_Tag.Value = player
  96. Services.Debris:AddItem(Creator_Tag, 2)
  97. Creator_Tag.Parent = humanoid
  98. end
  99.  
  100. function UntagHumanoid(humanoid)
  101. for i, v in pairs(humanoid:GetChildren()) do
  102. if v:IsA("ObjectValue") and v.Name == "creator" then
  103. v:Destroy()
  104. end
  105. end
  106. end
  107.  
  108. local function EnableParticles(Verdict)
  109. for _,stuff in pairs(Handle:GetDescendants()) do
  110. if (stuff:IsA("ParticleEmitter") and stuff.Parent ~= Handle) or stuff:IsA("Light") then
  111. stuff.Enabled = Verdict
  112. end
  113. if stuff:IsA("Light") then
  114. stuff.Range = (Verdict and 10) or 3
  115. end
  116. end
  117. end
  118.  
  119. local function SpecialParticles(Verdict)
  120. for _,stuff in pairs(Handle:GetDescendants()) do
  121. if stuff:IsA("ParticleEmitter") and stuff.Parent == Handle then
  122. stuff.Enabled = Verdict
  123. end
  124. if stuff:IsA("Beam") then
  125. stuff.TextureSpeed = (Verdict and 1) or .1
  126. stuff.Color = (Verdict and ColorSequence.new(Color3.new(1,1,1)) or ColorSequence.new(Color3.new(.5,.5,.5)))
  127. end
  128. end
  129. end
  130.  
  131.  
  132.  
  133. local Player,Character,Humanoid,Root
  134.  
  135. function PassiveSpecial()
  136. --Sword of light does healing + Damage resistance when the sun is out
  137. --Check if Daytime then roll with ability
  138. --loop until time is not daytime
  139. if not Humanoid or Humanoid.Health <= 0 or not Character then return end
  140.  
  141. if not SunIsVisible(Character) then
  142. --print("Sun is not visible")
  143. EnableParticles(false)
  144. Properties.SpecialActive = false
  145. if Humanoid and Tool:IsDescendantOf(Character) then
  146. Humanoid.WalkSpeed = 12
  147. Properties.Damage = 3
  148. end
  149. --[[Disable particles on sword]]
  150. return
  151. end
  152.  
  153. if Humanoid and Tool:IsDescendantOf(Character) then
  154. Humanoid.WalkSpeed = 15
  155. Properties.Damage = 3
  156. end
  157. --Trigger active particles on sword
  158.  
  159. if not Character:FindFirstChild(script:WaitForChild("SoLDefense").Name) and Tool:IsDescendantOf(Character) then
  160. local DefenseScript = script:WaitForChild("SoLDefense"):Clone()
  161. local ToolRef = Create("ObjectValue"){
  162. Name = "ToolRef",
  163. Value = Tool,
  164. Parent = DefenseScript
  165. }
  166. DefenseScript.Parent = Character
  167. DefenseScript.Disabled = false
  168. end
  169.  
  170.  
  171. if Properties.SpecialActive then --[[print("On Cooldown")]] return end
  172. --SwordMesh.VertexColor = Vector3.new(1,1,1) * 10 -- Make the sword look all bright
  173.  
  174. Properties.SpecialActive = true
  175. EnableParticles(true)
  176.  
  177.  
  178. end
  179.  
  180. local Animations = {}
  181.  
  182. function ChangeTime(Time) --initiate the cool time-chaning effect!
  183. if not Properties.Special then return end
  184. --warn("Changing Time")
  185. Properties.Special = false
  186. SpecialParticles(false)
  187. Tool.Enabled = false
  188. Humanoid.WalkSpeed = 0
  189. Animations.Summon:Play()
  190. delay(3,function()
  191. PassiveSpecial()
  192. Tool.Enabled = true
  193. Animations.Summon:Stop()
  194. --Humanoid.WalkSpeed = (Humanoid.WalkSpeed <=0 and 16) or Humanoid.WalkSpeed
  195. end)
  196. delay(Properties.SpecialReload,function()
  197. Properties.Special = true
  198. SpecialParticles(true)
  199. end)
  200. local TimeChange = script:WaitForChild("TimeChange"):Clone()
  201. local SpawnPosition = Create("Vector3Value"){
  202. Name = "SpawnPosition",
  203. Value = Root.Position - Vector3.new(0,Root.Size.Y * 1.5,0),
  204. Parent = TimeChange,
  205. }
  206. local Creator = Create("ObjectValue"){
  207. Name = "Creator",
  208. Value = Player,
  209. Parent = TimeChange
  210. }
  211. local Time = Create("NumberValue"){
  212. Name = "Time",
  213. Value = Time,
  214. Parent = TimeChange
  215. }
  216. TimeChange.Parent = Services.ServerScriptService
  217. TimeChange.Disabled = false
  218. end
  219.  
  220. local function LightTransport()
  221. local LightWarpScript = script:WaitForChild("LightWarp")
  222. local function IsWarping()
  223. local stuff = Services.ServerScriptService:GetChildren()
  224. for i=1,#stuff do
  225. if stuff[i] and stuff[i].Name == LightWarpScript.Name and stuff[i]:FindFirstChild("Character") and stuff[i]:FindFirstChild("Character").Value == Character then
  226. return true
  227. end
  228. end
  229. return false
  230. end
  231.  
  232. if IsWarping() then return end
  233.  
  234. local sucess,MousePosition = pcall(function() return MousePos:InvokeClient(Player) end)
  235. MousePosition = (sucess and MousePosition) or Vector3.new(0,0,0)
  236.  
  237. LightWarpScript = LightWarpScript:Clone()
  238. local CharacterTag = Create("ObjectValue"){
  239. Name = "Character",
  240. Value = Character,
  241. Parent = LightWarpScript
  242. }
  243. local TargetLocation = Create("Vector3Value"){
  244. Name = "TargetLocation",
  245. Value = MousePosition,
  246. Parent = LightWarpScript
  247. }
  248. local Range = Create("NumberValue"){
  249. Name = "Range",
  250. Value = (Properties.SpecialActive and 200) or 100,
  251. Parent = LightWarpScript
  252. }
  253. LightWarpScript.Parent = Services.ServerScriptService
  254. LightWarpScript.Disabled = false
  255. end
  256.  
  257. local EquippedEvents = {}
  258. local Touch
  259.  
  260.  
  261.  
  262. local MouseHeld = false
  263. local CurrentMotor,RightWeld,Part0,Part1
  264.  
  265. function Equipped()
  266. Character = Tool.Parent
  267. Player = Services.Players:GetPlayerFromCharacter(Character)
  268. Humanoid = Character:FindFirstChildOfClass("Humanoid")
  269. Root = Character:WaitForChild("HumanoidRootPart")
  270.  
  271. if not Humanoid or Humanoid.Health <= 0 then return end
  272.  
  273. Animations = Tool:WaitForChild("Animations"):WaitForChild(Humanoid.RigType.Name)
  274. Animations = {
  275. Slash = Humanoid:LoadAnimation(Animations:WaitForChild("SlashAnim")),
  276. Stab = Humanoid:LoadAnimation(Animations:WaitForChild("StabAnim")),
  277. Summon = Humanoid:LoadAnimation(Animations:WaitForChild("SummonAnim")),
  278. Charge = Humanoid:LoadAnimation(Animations:WaitForChild("ChargeAnim")),
  279. }
  280. Touch = Handle.Touched:Connect(function(hit)
  281. if not hit or not hit.Parent then return end
  282. local Hum,FF = hit.Parent:FindFirstChildOfClass("Humanoid"),hit.Parent:FindFirstChildOfClass("ForceField")
  283. if not Hum or FF or Hum.Health <= 0 or IsTeamMate(Services.Players:GetPlayerFromCharacter(Hum.Parent),Player) or Hum.Parent == Character then return end
  284. UntagHumanoid(Hum)
  285. TagHumanoid(Hum,Player)
  286. Hum:TakeDamage(Properties.Damage)
  287. print(Properties.Damage)
  288. end)
  289. PassiveSpecial()
  290. Sounds.Unsheath:Play()
  291. end
  292.  
  293.  
  294. function Unequipped()
  295. MouseHeld = false
  296. if Touch then Touch:Disconnect();Touch = nil end
  297. for AnimName,anim in pairs(Animations) do
  298. if anim then
  299. anim:Stop()
  300. end
  301. end
  302. if CurrentMotor then
  303. CurrentMotor:Destroy()
  304. end
  305. if Tool:IsDescendantOf(workspace) and not Tool:IsDescendantOf(Character) then
  306. for index = 1,#EquippedEvents do
  307. if EquippedEvents[index] then
  308. EquippedEvents[index]:Disconnect();EquippedEvents[index] = nil
  309. end
  310. end
  311. end
  312. end
  313.  
  314. local Seed = Random.new()
  315.  
  316. function Activated()
  317. if not Tool.Enabled or MouseHeld then return end
  318. MouseHeld = true
  319. Animations.Charge:Play()
  320. end
  321.  
  322. function Deactivated()
  323. if not Tool.Enabled or not MouseHeld then return end
  324. MouseHeld = false
  325.  
  326. Tool.Enabled = false
  327. local RightLimb = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
  328. if RightLimb then
  329. RightWeld = RightLimb:FindFirstChildOfClass("Weld")
  330. if RightWeld and not CurrentMotor then
  331. CurrentMotor = Create'Motor6D'{
  332. Name = 'Grip',
  333. --C0 = RightWeld.C0,
  334. --C1 = Tool.Grip,--RightWeld.C1,
  335. Part0 = RightWeld.Part0,
  336. Part1 = Handle,
  337. --Parent = RightArm
  338. }
  339. CurrentMotor.Parent = RightLimb
  340. end
  341. coroutine.wrap(function()
  342. if RightWeld then
  343. Part0 = RightWeld.Part0
  344. Part1 = RightWeld.Part1
  345. RightWeld.Part0 = nil
  346. RightWeld.Part1 = nil
  347. end
  348. end)()
  349.  
  350. end
  351. local AttackAnims = {--[[Animations.Slash,]]Animations.Stab}
  352. Sounds.Lunge:Play()
  353. Animations.Charge:Stop()
  354. local Anim = AttackAnims[Seed:NextInteger(1,#AttackAnims)]
  355. Anim:Play(0,nil,3);--Anim.Stopped:Wait()
  356. Wait(Anim.Length/3)
  357. if RightWeld then
  358. RightWeld.Part0 = Part0
  359. RightWeld.Part1 = Part1
  360. end
  361. if CurrentMotor then
  362. CurrentMotor:Destroy();CurrentMotor = nil
  363. end
  364. Tool.Enabled = true
  365. end
  366.  
  367.  
  368. Remote.OnServerEvent:Connect(function(Client,Key)
  369. if Client ~= Player or not Key or not Humanoid or Humanoid.Health <= 0 or not Tool.Enabled then return end
  370. if Key == Enum.KeyCode.Z then
  371. ChangeTime(Properties.TimetoChange)
  372. elseif Key == Enum.KeyCode.X and Properties.LightTeleport then
  373. Properties.LightTeleport = false
  374. delay(5,function()
  375. Properties.LightTeleport = true
  376. end)
  377. LightTransport()
  378. end
  379. end)
  380.  
  381. Tool.Equipped:Connect(Equipped)
  382. Tool.Unequipped:Connect(Unequipped)
  383. Tool.Activated:Connect(Activated)
  384. Tool.Deactivated:Connect(Deactivated)
  385.  
  386. Services.Lighting.Changed:Connect(function(property)
  387. if property == "ClockTime" then
  388. PassiveSpecial()
  389. end
  390. end)
  391. EnableParticles(false)
  392. SpecialParticles(true)
  393. PassiveSpecial()--trigger it initially on start
  394.  
  395.  
Advertisement
Add Comment
Please, Sign In to add comment