Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- B = script.Parent F = script.Parent
- local prop = game.ServerStorage.Props.Breakables.brokenBarrel --Broken Version of prop
- script.Parent.Healthy.Changed:connect(function(health)
- if script.Parent.Healthy.Value < 1 then --if props health is reduced to 0
- local x = prop:Clone() x.Parent = game.Workspace x:SetPrimaryPartCFrame(script.Parent.BarrelCore.CFrame)
- --replace prop with broken version
- x:BreakJoints() B:Destroy() F = x --remove old version and destroy welds on broken version
- for C, D in pairs(x:GetChildren()) do D.CollisionGroupId = 1 --prevent player from colliding with debris
- local bp = Instance.new("BodyThrust") -- sends debris flying in random directions
- bp.Parent = D
- bp.Force = Vector3.new (math.random(-3000,3000),math.random(-3000,3000),math.random(-3000,3000));
- wait(.001)
- bp:Destroy()
- end
- for C, D in pairs(F:GetChildren()) do
- wait(.1)
- game:GetService("Debris"):AddItem(D, .13) -- clean up debris
- end
- end end)
- script.Parent.hitReceptor.Changed:connect(function(hit) --ability to take damage
- if script.Parent.hitReceptor.Value == true then wait(.4) script.Parent.hitReceptor.Value = false
- --end
- end end)
Advertisement
Add Comment
Please, Sign In to add comment