Vex 2.0 | Complete Rewrite
Hello everybody! A long, long time ago (over 3 years ago) I set out to create a tool for the community. Derived from @Doglord120’s previous module (which is probably lost to time), it was a rough and crude implement of… essentially a 3D rasterizer. I have been reached out to many times and incentivized to fix Vex but grew to ignore it. Today, that ends!
Vex 2.0 is a module created to convert parts to smaller voxel parts. It is a complete back-end solution with the ability to apply forces to voxels, greedy meshing for performance needs, improved grid storage, and plenty more configuration. It is a whole redesign of Vex and intended to be (benchmarks pending) incredibly faster, more efficient, and versatile at it’s job.
What Changed
I rewrote the entire thing from scratch. Here’s the big stuff:
Performance
- Greedy meshing algorithm - combines adjacent voxels into larger parts instead of spamming thousands of 1x1x1 cubes
- Object pooling - reuses parts instead of constantly creating and destroying them
- Sparse grid storage - only stores voxels that actually exist
- Safety limits so you can’t accidentally crash your server
Features
- Apply forces to voxels (for explosions and stuff)
- Auto-cleanup with a
lifetimeparameter - Custom voxel sizes - not stuck at 1x1x1 anymore
- Voxels inherit material and color from the source
- Collision group support
- Actually works with Models now, not just individual parts
Code Quality
- Clean API that doesn’t suck to use
- Modular - 5 separate modules instead of one giant mess
- Input validation so it tells you when you’re doing something wrong
Installation
Get it here: Vex 2.0 - Roblox
Just insert it into your game and put the Vex ModuleScript in ReplicatedStorage. There are 4 child modules inside (Config, VoxelGrid, GreedyMesher, VoxelPool) - don’t separate them.
Optional: Create a collision group called “Debris” and set it to not collide with itself for better performance.
Quick Start
Basic usage:
local Vex = require(ReplicatedStorage.Vex)
local structure = Vex.new(workspace.Building)
structure:Destroy()
With configuration:
local structure = Vex.new(workspace.Building, {
voxelSize = 2, -- bigger voxels = better performance
useGreedyMesh = true, -- default, keep it on
maxVoxels = 5000, -- safety limit
lifetime = 30, -- auto-cleanup after 30 seconds
material = Enum.Material.Concrete,
collisionGroup = "Debris",
weldAdjacent = true -- welds nearby voxels together
})
structure:Destroy()
Explosion effect:
local structure = Vex.new(workspace.Building, {
voxelSize = 1.5,
lifetime = 20
})
structure:Destroy()
-- apply force at the explosion point
structure:ApplyForce(
Vector3.new(0, 800, 0),
explosionPosition
)
API Overview
I’m not going to list every single parameter here - check the README module that comes with the download for full docs.
Main stuff you need to know
Vex.new(model, config) - Creates a structure. Doesn’t destroy it yet.
structure:Destroy() - Actually breaks it into voxels.
structure:ApplyForce(force, position) - Applies physics force to nearby voxels. Useful for explosions.
structure:Cleanup() - Removes all voxels immediately.
structure:GetVoxelCount() - Returns how many parts are currently active.
Config options:
voxelSize- size of individual voxels (default: 1)useGreedyMesh- combines adjacent voxels for performance (default: true, keep it on)maxVoxels- safety limit to prevent crashes (default: 10000)lifetime- auto-cleanup in seconds (default: nil, never cleanup)material- override the source material (default: nil, inherits from source)anchored- whether voxels should be anchored (default: false)weldAdjacent- welds nearby voxel clusters (default: true)
Performance Tips
-
Keep greedy meshing on - It’s the default for a reason. Reduces part count massively for solid structures.
-
Use larger voxel sizes for big structures -
voxelSize = 2or3makes a huge difference. You don’t need hyper-detailed voxels for everything. -
Set maxVoxels limits - Don’t let someone destroy a 500-stud building and spawn 200k parts.
-
Use the lifetime parameter - Debris accumulates fast. Set it to auto-cleanup after 30-60 seconds.
-
Collision groups - Make a “Debris” group that doesn’t collide with itself. Physics will thank you.
Examples
Destructible wall
local Vex = require(ReplicatedStorage.Vex)
local wall = workspace.Wall
local structure = Vex.new(wall, {
voxelSize = 2,
lifetime = 15
})
workspace.Projectile.Touched:Connect(function(hit)
if hit == wall then
structure:Destroy()
structure:ApplyForce(
workspace.Projectile.AssemblyLinearVelocity * 10,
workspace.Projectile.Position
)
end
end)
Timed demolition
local Vex = require(ReplicatedStorage.Vex)
for i = 3, 1, -1 do
print(i)
wait(1)
end
print("BOOM!")
local structure = Vex.new(workspace.Building, {
voxelSize = 2,
lifetime = 30,
weldAdjacent = false -- let pieces fall independently
})
structure:Destroy()
structure:ApplyForce(Vector3.new(0, 1200, 0), workspace.Building.Position)
Known Issues / Limitations
- Only works with BaseParts right now. MeshParts and Unions aren’t supported yet.
- Rotated parts work but might have slight alignment weirdness.
- Extremely large structures (like 50k+ studs³) can still cause issues.
- Server-side only for now.
What’s Next
Things I want to add eventually:
- Client-side voxelization with server replication
- MeshPart/Union support
- Structural integrity (unsupported blocks collapse)
- Fire propagation through structures
- Maybe a Studio plugin for easier setup
No promises on timeline though.
Feedback
Let me know if you:
- Find bugs
- Have performance issues
- Want specific features
- Build something cool with it
If Vex 2.0 ends up in your game, tag me so I can check it out!
Download: Vex 2.0 - Roblox Model
License: MIT - use it however you want
Thanks to @Doglord120 for the original concept, and everyone who kept asking me to fix the old version. Here it is.