Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Name = "Shield"
- wait(0.25)
- if owner == nil then script:Destroy() return end
- local PartB = Instance.new("Part")
- local SB = Instance.new("Sound",PartB)
- SB.SoundId = "rbxasset://sounds/impact_explosion_03.mp3"
- SB.Volume = 1.4
- SB.PlayOnRemove = true
- local PartC = Instance.new("Part")
- local SC = Instance.new("Sound",PartC)
- SC.SoundId = "rbxasset://sounds/collide.wav"
- SC.Volume = 1.4
- SC.PlayOnRemove = true
- local PartD = Instance.new("Part")
- local SD = Instance.new("Sound",PartD)
- SD.SoundId = "rbxasset://sounds/Rocket shot.wav"
- SD.Volume = 1.4
- SD.PlayOnRemove = true
- PartB.Anchored = true
- PartC.Anchored = true
- PartD.Anchored = true
- function HitSound(pos)
- local random = math.random(1,3)
- if random == 1 then
- if SB and SB.Parent then
- SB.PlaybackSpeed = math.random(240,360) / 100
- end
- if PartB then
- PartB.Position = pos
- PartB.Parent = script
- PartB.Parent = nil
- end
- elseif random == 2 then
- if SC then
- SC.PlaybackSpeed = math.random(140,360) / 100
- end
- if PartC then
- PartC.Position = pos
- PartC.Parent = script
- PartC.Parent = nil
- end
- elseif random == 3 then
- if SD then
- SD.PlaybackSpeed = math.random(1600,2000) / 100
- end
- if PartD then
- PartD.Position = pos
- PartD.Parent = script
- PartD.Parent = nil
- end
- end
- end
- function Kaboom(pos)
- local random = math.random(1,3)
- if random == 1 then
- if SB and SB.Parent then
- SB.PlaybackSpeed = math.random(80,160) / 100
- end
- if PartB then
- PartB.Position = pos
- PartB.Parent = script
- PartB.Parent = nil
- end
- elseif random == 2 then
- if SC then
- SC.PlaybackSpeed = math.random(60,120) / 100
- end
- if PartC then
- PartC.Position = pos
- PartC.Parent = script
- PartC.Parent = nil
- end
- elseif random == 3 then
- if SD then
- SD.PlaybackSpeed = math.random(120,240) / 100
- end
- if PartD then
- PartD.Position = pos
- PartD.Parent = script
- PartD.Parent = nil
- end
- end
- end
- function NearNumber(a,b)
- if a + 0.375 >= b and a - 0.375 <= b then
- return true
- else
- return false
- end
- end
- function Hit(hit,p,o,d,s,t)
- if hit and hit.Parent then
- local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
- if Humanoid then
- if p then
- p:Emit(100)
- end
- Humanoid:TakeDamage(12)
- local creator = Instance.new("ObjectValue",Humanoid)
- creator.Name = "creator"
- if o and o.Parent then
- creator.Value = o
- end
- game:GetService("Debris"):AddItem(creator,0.2)
- if s then
- Humanoid:TakeDamage(588)
- if d then
- d.PlaybackSpeed = 1.175
- d:Play()
- end
- end
- delay(0,function()
- HitSound(hit.Position)
- end)
- elseif Humanoid == nil and (hit:GetMass() < 120 or (s and hit:GetMass() < 2400)) then
- if p then
- p:Emit(100)
- end
- hit:BreakJoints()
- delay(0,function()
- HitSound(hit.Position)
- end)
- end
- local Tag2 = hit.Parent:FindFirstChild("FakeHumanoid")
- if Tag2 and o and o.Parent then
- Tag2.Value = o.Name
- end
- if s == true then
- if p then
- p:Emit(100)
- end
- delay(0,function()
- HitSound(hit.Position)
- end)
- local Direction = (hit.Position - t.Position).unit
- local BodyForce = Instance.new("BodyForce",hit)
- BodyForce.Force = Direction * 160000
- game:GetService("Debris"):AddItem(BodyForce,0.2)
- if math.random(1,32) == 1 then
- hit:BreakJoints()
- p:Emit(320)
- Kaboom(hit.Position)
- end
- end
- end
- end
- function Ready()
- local Tool = Instance.new("Tool",owner.Backpack)
- Tool.Name = "Shield"
- Tool.TextureId = "rbxasset://textures/blackBkg_round.png"
- Tool.GripPos = Vector3.new(1,0.5,0.5)
- local Torso = Instance.new("Part",Tool)
- Torso.Name = "Handle"
- Torso.Size = Vector3.new(4,4,1)
- Torso.BrickColor = BrickColor.new("Medium stone grey")
- Torso.Material = Enum.Material.Metal
- Torso.Locked = true
- Torso.CustomPhysicalProperties = PhysicalProperties.new(Enum.Material.Metal)
- local SoundA = Instance.new("Sound",Torso)
- SoundA.SoundId = "rbxasset://sounds/swordslash.wav"
- SoundA.Volume = 1.2
- local SoundB = Instance.new("Sound",Torso)
- SoundB.SoundId = "rbxasset://sounds/Shoulder fired rocket.wav"
- SoundB.Volume = 1.2
- local SoundC = Instance.new("Sound",Torso)
- SoundC.SoundId = "rbxasset://sounds/flashbulb.wav"
- SoundC.Volume = 1.2
- local SoundD = Instance.new("Sound",Torso)
- SoundD.SoundId = "rbxasset://sounds/Kid saying Ouch.wav"
- SoundD.Volume = 1.2
- local A = Instance.new("Attachment",Torso)
- local Particles = Instance.new("ParticleEmitter",A)
- Particles.LightEmission = 1
- Particles.LightInfluence = 0.2
- Particles.Drag = 16
- Particles.Enabled = false
- Particles.Lifetime = NumberRange.new(0.1,0.4)
- Particles.Rate = 100
- Particles.Rotation = NumberRange.new(-360,360)
- Particles.SpreadAngle = Vector2.new(-360,360)
- Particles.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,0),NumberSequenceKeypoint.new(0.8,0),NumberSequenceKeypoint.new(1,1)})
- Particles.Texture = "rbxasset://textures/particles/sparkles_main.dds"
- Particles.Speed = NumberRange.new(70,70)
- Particles.Size = NumberSequence.new(0.7,0.7)
- local BA0 = Instance.new("Attachment",Torso)
- BA0.Position = Vector3.new(-2,0,0.5)
- local BA1 = Instance.new("Attachment",Torso)
- BA1.Position = Vector3.new(2,0,0.5)
- local ShipTrail = Instance.new("Trail",script)
- ShipTrail.Color = ColorSequence.new(Torso.Color)
- ShipTrail.Transparency = NumberSequence.new(0,1)
- ShipTrail.MinLength = 0.02
- ShipTrail.Lifetime = 0.3
- ShipTrail.FaceCamera = true
- ShipTrail.Attachment0 = BA0
- ShipTrail.Attachment1 = BA1
- local Beam = Instance.new("Beam",script)
- Beam.Attachment0 = A
- Beam.FaceCamera = true
- local Bill = Instance.new("BillboardGui",script)
- Bill.Size = UDim2.new(16,0,16,0)
- local Image = Instance.new("ImageLabel",Bill)
- Image.Image = "rbxasset://textures/sparkle.png"
- Image.Size = UDim2.new(1,0,1,0)
- Image.Position = UDim2.new(0.5,0,0.5,0)
- Image.AnchorPoint = Vector2.new(0.5,0.5)
- Image.ImageTransparency = 1
- Image.BackgroundTransparency = 1
- Fire = 0
- local Resistance = 200
- local Connection
- local CurrentHumanoid
- local CurrentHealth
- local LastSuper = false
- local function HealthChanged(NewHealth)
- if CurrentHumanoid ~= nil then
- if CurrentHumanoid.Health < CurrentHealth then
- Resistance = Resistance - math.min(CurrentHealth - CurrentHumanoid.Health,60)
- CurrentHumanoid.Health = CurrentHealth
- if Torso then
- HitSound(Torso.Position)
- Bill.StudsOffsetWorldSpace = Torso.Position
- Image.ImageColor3 = Torso.Color
- Image.ImageTransparency = 0
- end
- if Resistance <= 0 then
- local Player = game:GetService("Players"):GetPlayerFromCharacter(CurrentHumanoid.Parent)
- if Player then
- Tool.Parent = Player:FindFirstChildWhichIsA("Backpack")
- else
- Tool.Parent = nil
- end
- end
- end
- if CurrentHumanoid ~= nil then
- CurrentHealth = CurrentHumanoid.Health
- end
- end
- end
- local function Equipped()
- Resistance = math.max(80,Resistance)
- Fire = math.max(-55,math.min(0,Fire))
- Tool.Enabled = true
- local Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
- if Humanoid then
- CurrentHumanoid = Humanoid
- CurrentHealth = Humanoid.Health
- Connection = Humanoid.HealthChanged:Connect(HealthChanged)
- end
- end
- local function Unequipped()
- local a = Connection
- local b = CurrentHumanoid
- if a then
- a:Disconnect()
- end
- if CurrentHumanoid then
- CurrentHumanoid = nil
- end
- local ch = b.Health
- local Connect = b.HealthChanged:Connect(function(NewHealth)
- if b.Health < ch then
- if Torso then
- HitSound(Torso.Position)
- Bill.StudsOffsetWorldSpace = Torso.Position
- Image.ImageColor3 = Torso.Color
- Image.ImageTransparency = 0
- end
- b.Health = ch
- end
- ch = b.Health
- end)
- delay(0.8,function()
- Connect:Disconnect()
- end)
- end
- Tool.Equipped:Connect(Equipped)
- Tool.Unequipped:Connect(Unequipped)
- local function Touched(hit)
- local Player = game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
- local Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
- if Humanoid and Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and Fire > 0 then
- Hit(hit,Particles,Player,SoundD,LastSuper,Torso)
- if SoundC then
- SoundC.PlaybackSpeed = 1.6
- SoundC:Play()
- end
- if Particles then
- Particles.Color = ColorSequence.new(Torso.Color)
- Particles:Emit(16)
- end
- end
- end
- Torso.Touched:Connect(Touched)
- local function ValueChange()
- if Tool.Enabled == false then
- if Torso and Fire <= 0 then
- local Player = game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
- local Character = Tool.Parent
- local Humanoid
- if Character then
- Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
- end
- if Humanoid and Humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
- local Super = (Fire <= -75)
- local LaunchDirection = Vector3.new(0,0,0)
- local Launch = false
- if Humanoid.MoveDirection.X ~= 0 or Humanoid.MoveDirection.Z ~= 0 then
- LaunchDirection = Torso.CFrame.lookVector
- Launch = true
- end
- if Humanoid:GetState() ~= Enum.HumanoidStateType.Running and Humanoid:GetState() ~= Enum.HumanoidStateType.RunningNoPhysics then
- LaunchDirection = LaunchDirection + Vector3.new(0,2,0)
- if Launch == true then
- LaunchDirection = LaunchDirection + Vector3.new(0,-1,0)
- end
- Launch = true
- end
- LastSuper = false
- if Super == true then
- LastSuper = true
- end
- if Super and Launch then
- local toolanim = Instance.new("StringValue",Tool)
- toolanim.Name = "toolanim"
- toolanim.Value = "Lunge"
- else
- local toolanim = Instance.new("StringValue",Tool)
- toolanim.Name = "toolanim"
- toolanim.Value = "Slash"
- end
- if Super == true and Launch == true then
- SoundB.PlaybackSpeed = 1.75
- SoundB:Play()
- if Humanoid.SeatPart == nil then
- Humanoid.PlatformStand = false
- Humanoid.Sit = false
- Humanoid.Jump = true
- elseif LaunchDirection.Y > 0 then
- LaunchDirection = Vector3.new(LaunchDirection.X,LaunchDirection.Y * 0.2,LaunchDirection.Z)
- end
- local BodyVelocity = Instance.new("BodyVelocity",Torso)
- BodyVelocity.MaxForce = Vector3.new(1000000,100000,1000000)
- BodyVelocity.Velocity = LaunchDirection * 120
- game:GetService("Debris"):AddItem(BodyVelocity,0.6)
- end
- if SoundA then
- SoundA.PlaybackSpeed = 1.4
- SoundA:Play()
- end
- Fire = 12
- if Super == true then
- Fire = 16
- end
- end
- end
- end
- end
- Tool:GetPropertyChangedSignal("Enabled"):Connect(ValueChange)
- local function Activated()
- Tool.Enabled = false
- end
- Tool.Activated:Connect(Activated)
- while Tool and Tool:FindFirstAncestorWhichIsA("DataModel") do
- Image.ImageTransparency = Image.ImageTransparency + 0.1
- Torso.CanCollide = true
- Resistance = math.min(200,Resistance + 0.125)
- Fire = Fire - 1
- if Fire == 0 then
- Tool.Enabled = true
- end
- if Torso and Fire <= -75 then
- Torso.Material = Enum.Material.Neon
- elseif Torso then
- Torso.Material = Enum.Material.Metal
- end
- Tool.ToolTip = "R = "..math.ceil(Resistance)
- if Torso then
- if Resistance > 160 then
- Torso.BrickColor = BrickColor.new("Toothpaste")
- if ShipTrail then
- ShipTrail.Color = ColorSequence.new(Color3.new(0,1,1))
- end
- elseif Resistance > 120 then
- Torso.BrickColor = BrickColor.new("Lime green")
- if ShipTrail then
- ShipTrail.Color = ColorSequence.new(Color3.new(0,1,0))
- end
- elseif Resistance > 80 then
- Torso.BrickColor = BrickColor.new("New Yeller")
- if ShipTrail then
- ShipTrail.Color = ColorSequence.new(Color3.new(1,1,0))
- end
- elseif Resistance > 40 then
- Torso.BrickColor = BrickColor.new("Hot pink")
- if ShipTrail then
- ShipTrail.Color = ColorSequence.new(Color3.new(1,0,1))
- end
- else
- Torso.BrickColor = BrickColor.new("Really red")
- if ShipTrail then
- ShipTrail.Color = ColorSequence.new(Color3.new(1,0,0))
- end
- end
- end
- if owner and owner.Parent and owner.Neutral == false then
- local TeamColor = owner.TeamColor
- Torso.BrickColor = TeamColor
- end
- wait(0.04)
- end
- end
- Ready()
- game:GetService("Debris"):AddItem(script)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement