need help to figure out how to throw the parts in random directions, tried Velocity, VectorForce and Explosion.
code:
local exploding = false
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local hum = c:FindFirstChild("Humanoid")
hum.Changed:Connect(function()
if hum and hum.Health == 0 and exploding == false then
explode(c.PrimaryPart.Position, c.PrimaryPart.BrickColor)
exploding = true
end
end)
end)
end)
function explode(pos, color)
for i = 0, 20, 1 do
local p = Instance.new("Part", workspace)
p.Size = Vector3.new(1,1,1)
p.Position = pos
p.BrickColor = color
end
end
local exploding = false
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local hum = c:FindFirstChild("Humanoid")
hum.Changed:Connect(function()
if hum and hum.Health == 0 and exploding == false then
explode(c.PrimaryPart.Position, c.PrimaryPart.BrickColor)
exploding = true
end
end)
end)
end)
function explode(pos, color)
for i = 0, 20, 1 do
local p = Instance.new("Part", workspace)
p.Anchored = false
p.Size = Vector3.new(1,1,1)
p.Position = pos
p.BrickColor = color
end
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- damages terrain
explosion.Position = pos
explosion.Parent = workspace
end