Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = owner
- script.Name = "Forcefield"
- wait(0.25)
- if Player == nil then script:Destroy() return end
- repeat wait() until Player.Character
- local Character = Player.Character
- local Forcefield = nil
- local ForcefieldHealth = 800
- local Tool = Instance.new("Tool",Player.Backpack)
- Tool.Name = "Forcefield"
- Tool.ToolTip = "Protect yourself from the threats outside!"
- Tool.TextureId = "rbxasset://textures/shadowblurmask.png"
- Tool.Grip = CFrame.new(0.0579372346, 0.0201288164, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
- local Remote = Instance.new("Part",Tool)
- Remote.Name = "Handle"
- Remote.Material = Enum.Material.ForceField
- Remote.BrickColor = BrickColor.new("Toothpaste")
- Remote.Size = Vector3.new(1.1,2.75,1.1)
- Remote.CanCollide = false
- Remote.Massless = true
- Tool.Equipped:Connect(function()
- Character = Tool.Parent
- Player = game:GetService("Players"):FindFirstChild(Tool.Parent.Name)
- Forcefield = Instance.new("Part",workspace)
- Forcefield.BrickColor = BrickColor.new("Toothpaste")
- Forcefield.Material = Enum.Material.ForceField
- Forcefield.Shape = Enum.PartType.Ball
- Forcefield.Size = Vector3.new(20,20,20)
- Forcefield.CanCollide = false
- Forcefield.CastShadow = false
- Forcefield.Massless = true
- local ForcefieldWeld = Instance.new("Weld",Forcefield)
- ForcefieldWeld.Part1 = Forcefield
- ForcefieldWeld.Part0 = Character.HumanoidRootPart
- UpdateForcefield()
- local Sound = Instance.new("Sound",Forcefield)
- Sound.SoundId = "rbxasset://sounds/bass.wav"
- Sound.Volume = 2
- Sound:Play()
- local Connection = Forcefield.Touched:Connect(function() end)
- game.Debris:AddItem(Sound,3)
- CreateSparks(Remote)
- end)
- Tool.Unequipped:Connect(function()
- Forcefield:Destroy()
- end)
- function CreateSparks(Part)
- local Sparkles = Instance.new("ParticleEmitter",Part)
- local SparklesKeypointsSize = {
- NumberSequenceKeypoint.new(0,2),
- NumberSequenceKeypoint.new(1,0)
- }
- Sparkles.Size = NumberSequence.new(SparklesKeypointsSize)
- Sparkles.SpreadAngle = Vector2.new(50000000,5e+07)
- Sparkles.Color = ColorSequence.new(Color3.fromRGB(255,255,255))
- Sparkles.LightEmission = 0.5
- Sparkles.LightInfluence = 0
- Sparkles.Lifetime = NumberRange.new(1)
- Sparkles.Drag = 5
- Sparkles.Speed = NumberRange.new(10)
- Sparkles.LockedToPart = true
- Sparkles.Enabled = false
- Sparkles:Emit(100)
- game.Debris:AddItem(Sparkles,3)
- end
- function UpdateForcefield()
- spawn(function()
- if Forcefield ~= nil then
- if ForcefieldHealth >= 600 and ForcefieldHealth <= 800 then
- Forcefield.BrickColor = BrickColor.new("Toothpaste")
- Remote.BrickColor = BrickColor.new("Toothpaste")
- elseif ForcefieldHealth >= 400 and ForcefieldHealth <= 600 then
- Forcefield.BrickColor = BrickColor.new("Lime green")
- Remote.BrickColor = BrickColor.new("Lime green")
- elseif ForcefieldHealth >= 200 and ForcefieldHealth <= 400 then
- Forcefield.BrickColor = BrickColor.new("New Yeller")
- Remote.BrickColor = BrickColor.new("New Yeller")
- Forcefield.Size = Vector3.new(20,20,20)
- elseif ForcefieldHealth == 0 then
- Forcefield.BrickColor = BrickColor.new("Black")
- Remote.BrickColor = BrickColor.new("Black")
- Forcefield.Size = Vector3.new(7,7,7)
- end
- end
- local Sound = Instance.new("Sound",Forcefield)
- Sound.SoundId = "rbxasset://sounds/snap.mp3"
- Sound.PlaybackSpeed = ForcefieldHealth/300
- Sound.Volume = 1.5
- Sound:Play()
- game.Debris:AddItem(Sound,4)
- end)
- end
- spawn(function()
- while true do
- wait()
- if Forcefield ~= nil then
- for i,v in pairs(Forcefield:GetTouchingParts()) do
- if not v:IsDescendantOf(Character) and v.Size.X*v.Size.Y*v.Size.Z < 1000 then
- if ForcefieldHealth > 24 and Forcefield.BrickColor ~= BrickColor.new("Black") then
- local Part = Instance.new("Part",Character.HumanoidRootPart)
- Part.Anchored = true
- Part.CanCollide = false
- Part.Transparency = 1
- Part.Size = Vector3.new(.25,.25,.25)
- Part.CFrame = CFrame.new(v.Position)
- game.Debris:AddItem(Part,3)
- local Sound = Instance.new("Sound",Part)
- Sound.Volume = 2
- Sound.SoundId = "rbxasset://sounds/impact_explosion_03.mp3"
- Sound.PlaybackSpeed = 4
- Sound:Play()
- ForcefieldHealth = ForcefieldHealth-25
- v:Destroy()
- CreateSparks(Part)
- UpdateForcefield()
- end
- end
- end
- end
- end
- end)
- spawn(function()
- while wait(.5) do
- if Forcefield ~= nil then
- if ForcefieldHealth < 800 then
- ForcefieldHealth = ForcefieldHealth+25
- UpdateForcefield()
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement