Advertisement
fusionfriends

Forcefield

Jun 18th, 2019
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.47 KB | None | 0 0
  1. local Player = owner
  2. script.Name = "Forcefield"
  3. wait(0.25)
  4. if Player == nil then script:Destroy() return end
  5. repeat wait() until Player.Character
  6. local Character = Player.Character
  7. local Forcefield = nil
  8. local ForcefieldHealth = 800
  9. local Tool = Instance.new("Tool",Player.Backpack)
  10. Tool.Name = "Forcefield"
  11. Tool.ToolTip = "Protect yourself from the threats outside!"
  12. Tool.TextureId = "rbxasset://textures/shadowblurmask.png"
  13. Tool.Grip = CFrame.new(0.0579372346, 0.0201288164, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  14. local Remote = Instance.new("Part",Tool)
  15. Remote.Name = "Handle"
  16. Remote.Material = Enum.Material.ForceField
  17. Remote.BrickColor = BrickColor.new("Toothpaste")
  18. Remote.Size = Vector3.new(1.1,2.75,1.1)
  19. Remote.CanCollide = false
  20. Remote.Massless = true
  21. Tool.Equipped:Connect(function()
  22.     Character = Tool.Parent
  23.     Player = game:GetService("Players"):FindFirstChild(Tool.Parent.Name)
  24.     Forcefield = Instance.new("Part",workspace)
  25.     Forcefield.BrickColor = BrickColor.new("Toothpaste")
  26.     Forcefield.Material = Enum.Material.ForceField
  27.     Forcefield.Shape = Enum.PartType.Ball
  28.     Forcefield.Size = Vector3.new(20,20,20)
  29.     Forcefield.CanCollide = false
  30.     Forcefield.CastShadow = false
  31.     Forcefield.Massless = true
  32.     local ForcefieldWeld = Instance.new("Weld",Forcefield)
  33.     ForcefieldWeld.Part1 = Forcefield
  34.     ForcefieldWeld.Part0 = Character.HumanoidRootPart
  35.     UpdateForcefield()
  36.     local Sound = Instance.new("Sound",Forcefield)
  37.     Sound.SoundId = "rbxasset://sounds/bass.wav"
  38.     Sound.Volume = 2
  39.     Sound:Play()
  40.     local Connection = Forcefield.Touched:Connect(function() end)
  41.     game.Debris:AddItem(Sound,3)
  42.     CreateSparks(Remote)
  43. end)
  44. Tool.Unequipped:Connect(function()
  45.     Forcefield:Destroy()
  46. end)
  47. function CreateSparks(Part)
  48.     local Sparkles = Instance.new("ParticleEmitter",Part)
  49.     local SparklesKeypointsSize = {
  50.         NumberSequenceKeypoint.new(0,2),
  51.         NumberSequenceKeypoint.new(1,0)
  52.     }
  53.     Sparkles.Size = NumberSequence.new(SparklesKeypointsSize)
  54.     Sparkles.SpreadAngle = Vector2.new(50000000,5e+07)
  55.     Sparkles.Color = ColorSequence.new(Color3.fromRGB(255,255,255))
  56.     Sparkles.LightEmission = 0.5
  57.     Sparkles.LightInfluence = 0
  58.     Sparkles.Lifetime = NumberRange.new(1)
  59.     Sparkles.Drag = 5
  60.     Sparkles.Speed = NumberRange.new(10)
  61.     Sparkles.LockedToPart = true
  62.     Sparkles.Enabled = false
  63.     Sparkles:Emit(100)
  64.     game.Debris:AddItem(Sparkles,3)
  65. end
  66. function UpdateForcefield()
  67.     spawn(function()
  68.         if Forcefield ~= nil then
  69.             if ForcefieldHealth >= 600 and ForcefieldHealth <= 800 then
  70.                 Forcefield.BrickColor = BrickColor.new("Toothpaste")
  71.                 Remote.BrickColor = BrickColor.new("Toothpaste")
  72.             elseif ForcefieldHealth >= 400 and ForcefieldHealth <= 600 then
  73.                 Forcefield.BrickColor = BrickColor.new("Lime green")
  74.                 Remote.BrickColor = BrickColor.new("Lime green")
  75.             elseif ForcefieldHealth >= 200 and ForcefieldHealth <= 400 then
  76.                 Forcefield.BrickColor = BrickColor.new("New Yeller")
  77.                 Remote.BrickColor = BrickColor.new("New Yeller")
  78.                 Forcefield.Size = Vector3.new(20,20,20)
  79.             elseif ForcefieldHealth == 0 then
  80.                 Forcefield.BrickColor = BrickColor.new("Black")
  81.                 Remote.BrickColor = BrickColor.new("Black")
  82.                 Forcefield.Size = Vector3.new(7,7,7)
  83.             end
  84.         end
  85.         local Sound = Instance.new("Sound",Forcefield)
  86.         Sound.SoundId = "rbxasset://sounds/snap.mp3"
  87.         Sound.PlaybackSpeed = ForcefieldHealth/300
  88.         Sound.Volume = 1.5
  89.         Sound:Play()
  90.         game.Debris:AddItem(Sound,4)
  91.     end)
  92. end
  93. spawn(function()
  94.     while true do
  95.         wait()
  96.         if Forcefield ~= nil then
  97.             for i,v in pairs(Forcefield:GetTouchingParts()) do
  98.                 if not v:IsDescendantOf(Character) and v.Size.X*v.Size.Y*v.Size.Z < 1000 then
  99.                     if ForcefieldHealth > 24 and Forcefield.BrickColor ~= BrickColor.new("Black") then
  100.                         local Part = Instance.new("Part",Character.HumanoidRootPart)
  101.                         Part.Anchored = true
  102.                         Part.CanCollide = false
  103.                         Part.Transparency = 1
  104.                         Part.Size = Vector3.new(.25,.25,.25)
  105.                         Part.CFrame = CFrame.new(v.Position)
  106.                         game.Debris:AddItem(Part,3)
  107.                         local Sound = Instance.new("Sound",Part)
  108.                         Sound.Volume = 2
  109.                         Sound.SoundId = "rbxasset://sounds/impact_explosion_03.mp3"
  110.                         Sound.PlaybackSpeed = 4
  111.                         Sound:Play()
  112.                         ForcefieldHealth = ForcefieldHealth-25
  113.                         v:Destroy()
  114.                         CreateSparks(Part)
  115.                         UpdateForcefield()
  116.                     end
  117.                 end
  118.             end
  119.         end
  120.     end
  121. end)
  122. spawn(function()
  123.     while wait(.5) do
  124.         if Forcefield ~= nil then
  125.             if ForcefieldHealth < 800 then
  126.                 ForcefieldHealth = ForcefieldHealth+25
  127.                 UpdateForcefield()
  128.             end
  129.         end
  130.     end
  131. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement