Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Bomb = {
- Tool = script.Parent,
- Handle = nil,
- MinDamage = 50,
- MaxDamage = 50,
- FireRate = 0,
- BombVelocity = 125,
- ChargeTime = 10,
- ExtraSize = 10,
- Equipped = false,
- LastFlap = 10,
- StartChargeAt = 10,
- Charging = false
- }
- local Debris = Game:GetService'Debris'
- --
- --
- function Bomb.Validate()
- assert(Bomb.Tool:WaitForChild'Handle':IsA'BasePart', 'Failed to find handle')
- assert(Bomb.Tool:WaitForChild'StartCharge':IsA'RemoteEvent', 'Failed to find StartCharge RemoteEvent')
- Bomb.Handle = Bomb.Tool.Handle
- end
- function Bomb.Initialize()
- end
- function Bomb.Start()
- Bomb.Validate()
- Bomb.Connect()
- Bomb.Initialize()
- end
- function Bomb.Connect()
- Bomb.Tool.Equipped:connect(Bomb.OnEquip)
- Bomb.Tool.Unequipped:connect(Bomb.OnUnequip)
- Bomb.Tool.StartCharge.OnServerEvent:connect(Bomb.StartCharge)
- Bomb.Tool.StopCharge.OnServerEvent:connect(Bomb.StopCharge)
- end
- function Bomb.StopCharge(player, targetPos)
- if player.Character == Bomb.Tool.Parent then
- Bomb.ShotTarget = targetPos
- Bomb.Charging = false
- end
- end
- function Bomb.StartCharge(player)
- if player.Character == Bomb.Tool.Parent then
- local character = Bomb.Tool.Parent
- local head, humanoid = character:FindFirstChild'Head', character:FindFirstChild'Humanoid'
- if head ~= nil and head:IsA'BasePart' and humanoid ~= nil and humanoid:IsA'Humanoid' then
- Bomb.StartChargeAt = tick()
- local lookAt = head.CFrame.lookVector
- local mesh = Bomb.Handle:FindFirstChild'Mesh'
- if mesh and mesh:IsA'DataModelMesh' then
- mesh.Scale = Vector3.new(1,1,1)
- end
- local fire = Bomb.Handle:FindFirstChild'Fire'
- if fire and fire:IsA'Fire' then
- fire.Size = 0
- fire.Enabled = true
- end
- local lastChargeSound = 0
- Bomb.Charging = true
- while Bomb.Charging and Bomb.Equipped and tick()-Bomb.StartChargeAt < Bomb.ChargeTime and humanoid.Health > 0 do
- local alpha = (tick()-Bomb.StartChargeAt)/Bomb.ChargeTime
- Bomb.Handle.Transparency = 0.3+math.random()*0.3
- Bomb.Tool.GripPos = Vector3.new(0, 0, 0.5+Bomb.ExtraSize*0.5*alpha)
- if mesh ~= nil then
- mesh.Scale = Vector3.new(1,1,1) + Vector3.new(1,1,1)*Bomb.ExtraSize*alpha
- end
- if fire ~= nil then
- fire.Size = alpha*Bomb.ExtraSize*2
- end
- if tick() - lastChargeSound > 5 then
- lastChargeSound = tick()
- local sound = Bomb.Handle:FindFirstChild'ChargeSound'
- if sound and sound:IsA'Sound' then
- sound:Play()
- end
- end
- wait(0.5)
- end
- Bomb.Tool.GripPos = Vector3.new()
- Bomb.Handle.Transparency = 1
- local sound = Bomb.Handle:FindFirstChild'ChargeSound'
- if sound and sound:IsA'Sound' then
- sound:Stop()
- end
- local sound = Bomb.Handle:FindFirstChild'FireSound'
- if sound and sound:IsA'Sound' then
- sound:Play()
- end
- local fire = Bomb.Handle:FindFirstChild'Fire'
- if fire and fire:IsA'Fire' then
- fire.Enabled = false
- end
- local shot = Bomb.Handle:Clone()
- local fire = shot:FindFirstChild'Fire'
- if fire and fire:IsA'Fire' then
- fire.Enabled = true
- end
- local alpha = math.min(math.max((tick()-Bomb.StartChargeAt)/Bomb.ChargeTime, 0), 1)
- local size = 1+ Bomb.ExtraSize*alpha
- shot.Size = Vector3.new(1,1,1)*size
- shot.Mesh.Scale = Vector3.new(1,1,1)*(size/shot.Size.Y)
- shot.Name = 'Effect'
- shot.CanCollide = false
- shot.Transparency = 0.4
- shot.Velocity = ((Bomb.ShotTarget - shot.Position).unit)*Bomb.BombVelocity
- shot.RotVelocity = Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*2*10
- local force = Instance.new'BodyForce'
- force.force = Vector3.new(0, shot:GetMass()*196.2, 0)
- force.Parent = shot
- shot.Touched:connect(function(hit)
- if shot~=nil and shot.Transparency ~= 1 and hit~=nil and hit.Name:lower():sub(1,6)~='effect' and hit.Name~='Handle' and hit.Name~='Water' then
- if not hit:IsDescendantOf(character) then
- local tCharacter = hit.Parent
- local tHumanoid = tCharacter:FindFirstChild'Humanoid'
- if tHumanoid and tHumanoid:IsA'Humanoid' then
- local canHurtPlayer = true
- local tPlayer = Game:GetService'Players':GetPlayerFromCharacter(tCharacter)
- if tPlayer and not tPlayer.Neutral and not player.Neutral and tPlayer.TeamColor==player.TeamColor then
- cnaHurtPlayer = false
- end
- if canHurtPlayer then
- for index, obj in next, tHumanoid:GetChildren() do
- if obj.Name == 'creator' and obj:IsA'ObjectValue' then
- obj.Parent = nil
- end
- end
- local tag = Instance.new'ObjectValue'
- tag.Name = 'creator'
- tag.Value = player
- tag.Parent = tHumanoid
- tHumanoid:TakeDamage(Bomb.MinDamage + (Bomb.MaxDamage*Bomb.MinDamage)*alpha)
- local sound = shot:FindFirstChild'ExplodeSound'
- if sound ~= nil and sound:IsA'Sound' then
- sound.Volume = 0.5+0.5*alpha
- sound:Play()
- end
- shot.Transparency = 1
- shot.Anchored = true
- local fire = shot:FindFirstChild'Fire'
- if fire and fire:IsA'Fire' then
- fire.Enabled = false
- end
- wait()
- if shot and shot.Parent then
- shot.Parent = nil
- end
- end
- end
- end
- end
- end)
- Debris:AddItem(shot, 14)
- shot.Parent = workspace
- end
- end
- end
- function Bomb.OnEquip()
- Bomb.Equipped = true
- end
- function Bomb.OnUnequip()
- Bomb.Equipped = false
- end
- --
- --
- Bomb.Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement