0% found this document useful (0 votes)
37 views5 pages

Roblox Module for Part Destruction

The document defines a Lua module for managing collision groups and effects on parts in a game environment. It includes functions for making parts fly up, burn, freeze, and destroy, while managing their attributes and visual effects like smoke and sparks. The module ensures that parts are properly handled and restored after a specified duration, enhancing gameplay interactions with physics-based elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views5 pages

Roblox Module for Part Destruction

The document defines a Lua module for managing collision groups and effects on parts in a game environment. It includes functions for making parts fly up, burn, freeze, and destroy, while managing their attributes and visual effects like smoke and sparks. The module ensures that parts are properly handled and restored after a specified duration, enhancing gameplay interactions with physics-based elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local module = {}

local PhysicsService = game:GetService("PhysicsService")


local cloneCollisionGroupName = "Parts"
local TweenService = game:GetService("TweenService")

local function setupCollisionGroups()


local groups = PhysicsService:GetCollisionGroups()
local groupExists = false
for _, group in ipairs(groups) do
if group == cloneCollisionGroupName then
groupExists = true
break
end
end

if not groupExists then


PhysicsService:CreateCollisionGroup(cloneCollisionGroupName)
end

PhysicsService:CollisionGroupSetCollidable(cloneCollisionGroupName,
cloneCollisionGroupName, false)
end
function [Link](v, duration)
if v:IsA("BasePart") and [Link] and [Link]:IsA("Model") then
local parentModel = [Link]
if not parentModel:GetAttribute("IsBeingDestroyed") then
parentModel:SetAttribute("IsBeingDestroyed", true)

if parentModel:GetAttribute("Destroyable") then
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = false
[Link] = 1
p:SetAttribute("Destroyable", false)

local clone = p:Clone()

[Link] = false
[Link] = true
[Link] = 0
[Link] = cloneCollisionGroupName

local smoke =
[Link]:Clone()
[Link] = clone
[Link] =
[Link]([Link])
wait(0.0002)
for _, v in ipairs(clone:GetDescendants()) do
if v:IsA("ParticleEmitter") and [Link] ==
"SMOKE" then
if v then
[Link] = true
v:Emit(20)
print("Emitting particles
from", [Link])
end
end
end
[Link] = [Link](0,
[Link](50, 80), 0) +
[Link] * [Link](-
30, 30) +
[Link] * [Link](-
30, 30)
[Link] =
[Link]([Link](-8, 8), [Link](-8, 8), [Link](-8, 8))
[Link] = workspace

local fadeOutTweenInfo = [Link](1,


[Link], [Link])
local fadeOutTween = TweenService:Create(clone,
fadeOutTweenInfo, {Transparency = 1})

[Link](duration - 1, function()
fadeOutTween:Play()
[Link]:Connect(function()
clone:Destroy()
end)
end)
end
end

[Link](duration, function()
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = true
[Link] = 0
p:SetAttribute("Destroyable", true)
end
end

parentModel:SetAttribute("IsBeingDestroyed", false)
end)
end
end
end
end

function [Link](v, duration)


if v:IsA("BasePart") and [Link] and [Link]:IsA("Model") then
local parentModel = [Link]
if not parentModel:GetAttribute("IsBeingDestroyed") then
parentModel:SetAttribute("IsBeingDestroyed", true)

if parentModel:GetAttribute("Destroyable") then
[Link] = true
[Link] = false
[Link] = 1
v:SetAttribute("Destroyable", false)

[Link](duration, function()
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") and p ~= v then
[Link] = true
[Link] = true
[Link] = 0
p:SetAttribute("Destroyable", true)
end
end
[Link] = true
[Link] = true
[Link] = 0
v:SetAttribute("Destroyable", true)

parentModel:SetAttribute("IsBeingDestroyed", false)
end)
end
end
end
end

function [Link](v, duration)


if v:IsA("BasePart") and [Link] and [Link]:IsA("Model") then
local parentModel = [Link]
if not parentModel:GetAttribute("IsBeingDestroyed") then
parentModel:SetAttribute("IsBeingDestroyed", true)

if parentModel:GetAttribute("Destroyable") then
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = false
[Link] = 1
p:SetAttribute("Destroyable", false)

local clone = p:Clone()

[Link] = false
[Link] = true
[Link] = 0
[Link] = cloneCollisionGroupName
[Link] = [Link]("Really
black")

local sparks =
[Link]:Clone()
[Link] = clone

local smoke =
[Link]:Clone()
[Link] = clone
[Link] =
[Link]([Link])
wait(0.0002)
for _, v in ipairs(clone:GetDescendants()) do
if v:IsA("ParticleEmitter") and [Link] ==
"SMOKE" then
if v then
[Link] = true
v:Emit(20)
print("Emitting particles
from", [Link])
end
end
end
[Link] = [Link](0,
[Link](50, 80), 0) +
[Link] * [Link](-
30, 30) +
[Link] * [Link](-
30, 30)
[Link] =
[Link]([Link](-8, 8), [Link](-8, 8), [Link](-8, 8))
[Link] = workspace

local fadeOutTweenInfo = [Link](1,


[Link], [Link])
local fadeOutTween = TweenService:Create(clone,
fadeOutTweenInfo, {Transparency = 1})

[Link](duration - 1, function()
fadeOutTween:Play()
[Link]:Connect(function()
clone:Destroy()
end)
end)
end
end

[Link](duration, function()
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = true
[Link] = 0
p:SetAttribute("Destroyable", true)
end
end

parentModel:SetAttribute("IsBeingDestroyed", false)
end)
end
end
end
end

function [Link](v, duration)


if v:IsA("BasePart") and [Link] and [Link]:IsA("Model") then
local parentModel = [Link]
if not parentModel:GetAttribute("IsBeingDestroyed") then
parentModel:SetAttribute("IsBeingDestroyed", true)

if parentModel:GetAttribute("Destroyable") then
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = false
[Link] = 1
p:SetAttribute("Destroyable", false)

local clone = p:Clone()


[Link] = false
[Link] = true
[Link] = 0
[Link] = cloneCollisionGroupName
[Link] = [Link](170, 255, 255)
[Link] = [Link]
[Link] = workspace
local smoke =
[Link]:Clone()
[Link] = clone
[Link] =
[Link]([Link])
wait(0.0002)
for _, v in ipairs(clone:GetDescendants()) do
if v:IsA("ParticleEmitter") and [Link] ==
"SMOKE" then
if v then
[Link] = true
v:Emit(20)
print("Emitting particles
from", [Link])
end
end
end
[Link]:AddItem(clone,duration)
end
end

[Link](duration, function()
for _, p in pairs(parentModel:GetDescendants()) do
if p:IsA("BasePart") then
[Link] = true
[Link] = true
[Link] = 0
p:SetAttribute("Destroyable", true)
end
end

parentModel:SetAttribute("IsBeingDestroyed", false)
end)
end
end
end
end

return module

You might also like