you had… a lot of syntax errors
script with errors fixed (not trying to fix the main problem):
local CloudID = "rbxassetid://1095708"
local ColorTexture = "rbxassetid://1361097"
local RingID = "rbxassetid://3270017"
local SphereID = "rbxassetid://1185246"
local BasePosition = script.Parent.CFrame
local Size = 1000
local Exp = Instance.new("Model")
Exp.Name = "ATOMICEXPLOSION"
Exp.Parent = workspace
local BasePart = Instance.new("Part")
BasePart.Anchored = true
BasePart.CanCollide = false
local CloudMesh = Instance.new("SpecialMesh")
CloudMesh.MeshType = "FileMesh"
CloudMesh.MeshId = CloudID
CloudMesh.TextureId = ColorTexture
CloudMesh.VertexColor = Vector3.new(0.9,0.6,0)
local RingMesh = Instance.new("SpecialMesh")
RingMesh.MeshType = "FileMesh"
RingMesh.MeshId = RingID
local SphereMesh = BaseMesh:Clone()
SphereMesh.MeshId = SphereID
local Clouds = {}
local ShockWave = {}
local Sky = script.Sky
function Effects()
script.Explode:Play()
task.spawn(function()
for i = 5, 1, -0.01 do
task.wait()
game.Lighting.Brightness = i
end
end)
end
function Destruction(Pos, Radius)
local function Destroy(Model)
for _, v in Model:GetDescendants() do
if v:IsA("BasePart") then
if (v.Position - Pos).Magnitude < Radius then
if not v.Anchored then
v:ApplyImpulse(math.random(1, 1000), 1000, math.random(1, 1000)
v.Material = "CorrodedMetal"
end
end
elseif v:IsA("Weld") or v:IsA("Motor6D") or v:IsA("WeldConstraint") then v:Destroy() end
end
end
end
Destroy(workspace)
end
function Explode(Pos)
local Base = BasePart:Clone()
Base.CFrame = CFrame.new(Pos)
local Mesh = CloudMesh:Clone()
Mesh.Parent = Base
Mesh.Scale = Vector3.new(2.5,1,4.5)
local PoleBase = BasePart:Clone()
PoleBase.CFrame = CFrame.new((Pos+Vector3.new(0,0.1,0)))
local PoleBaseMesh = CloudMesh:Clone()
PoleBaseMesh.Scale = Vector3.new(1.25,2,2.5)
PoleBaseMesh.Parent = PoleBase
local Cloud1 = BasePart:Clone()
Cloud1.CFrame = CFrame.new((Pos+Vector3.new(0,0.75,0)))
local Cloud1Mesh = CloudMesh:Clone()
Cloud1Mesh.Scale = Vector3.new(0.5,3,1)
Cloud1Mesh.Parent = Cloud1
local Cloud2 = BasePart:Clone()
Cloud2.CFrame = CFrame.new((Pos+Vector3.new(0,1.25,0)))
local Cloud2Mesh = CloudMesh:Clone()
Cloud2Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud2Mesh.Parent = Cloud2
local Cloud3 = BasePart:Clone()
Cloud3.CFrame = CFrame.new((Pos+Vector3.new(0,1.7,0)))
local Cloud3Mesh = CloudMesh:Clone()
Cloud3Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud3Mesh.Parent = Cloud3
local PoleRing = BasePart:Clone()
PoleRing.CFrame = CFrame.new((Pos+Vector3.new(0,1.3,0)))
PoleRing.Transparency = 0.2
PoleRing.BrickColor = BrickColor.new("Dark stone grey")
PoleRing.CFrame = PoleRing.CFrame*CFrame.Angles(math.rad(90),0,0)
local Mesh = RingMesh:Clone()
Mesh.Scale = Vector3.new(1.2,1.2,1.2)
Mesh.Parent = PoleRing
local MushCloud = BasePart:Clone()
MushCloud.CFrame = CFrame((Pos+Vector3.new(0,2.3,0)))
local MushMesh = CloudMesh:Clone()
MushMesh.Scale = Vector3.new(2.5,1.75,3.5)
MushMesh.Parent = MushCloud
local TopCloud = BasePart:Clone()
TopCloud.CFrame = CFrame.new((Pos+Vector3.new(0,2.7,0)))
local TopMesh = CloudMesh:Clone()
TopMesh.Scale = Vector3.new(7.5,1.5,1.5)
TopMesh.Parent = TopCloud
table.insert(Clouds, Base)
table.insert(Clouds, TopCloud)
table.insert(Clouds, MushCloud)
table.insert(Clouds, Cloud1)
table.insert(Clouds, Cloud2)
table.insert(Clouds, Cloud3)
table.insert(Clouds, PoleBase)
table.insert(Clouds, PoleRing)
local BigRing = BasePart:Clone()
BigRing.CFrame = CFrame.new(pos)
BigRing.CFrame = BigRing.CFrame*CFrame.Angles(math.rad(90),0,0)
local BigMesh = RingMesh:Clone()
BigMesh.Scale = Vector3.new(5,5,1)
BigMesh.Parent = BigRing
local SmallRing = BasePart:Clone()
SmallRing.CFrame = CFrame.new(Pos)
SmallRing.BrickColor = BrickColor.new("Dark stone grey")
SmallRing.CFrame = SmallRing.CFrame*CFrame.Angles(math.rad(90),0,0)
local SmallMesh = RingMesh:Clone()
SmallMesh.Scale = Vector3.new(4.6,4.6,1.5)
SmallMesh.Parent = SmallRing
local InnerSphere = BasePart:Clone()
InnerSphere.CFrame = CFrame.new(pos)
InnerSphere.BrickColor = BrickColor.new("Bright orange")
InnerSphere.Transparency = 0.5
local InnerSphereMesh = SphereMesh:Clone()
InnerSphereMesh.Scale = Vector3.new(-6.5,-6.5,-6.5)
InnerSphereMesh.Parent = InnerSphere
local OutterSphere = BasePart:Clone()
OutterSphere.CFrame = CFrame.new(Pos)
OutterSphere.BrickColor = BrickColor.new("Bright orange")
OutterSphere.Transparency = 0.5
local OutterSphereMesh = SphereMesh:Clone()
OutterSphereMesh.Scale = Vector3.new(6.5,6.5,6.5)
OutterSphereMesh.Parent = OutterSphere
table.insert(ShockWave, BigRing)
table.insert(ShockWave, SmallRing)
table.insert(ShockWave, OutterSphere)
table.insert(ShockWave, InnerSphere)
Sky.Parent = game.Lighting
for _, v in ShockWave do
v.Parent = Exp
end
for _, v in Clouds do
v.Parent = Exp
end
Effects()
task.spawn(function()
for resize = Size/2.5, Size*3, 2 do
task.wait()
BigRing.Mesh.Scale = Vector3.new(5*resize,5*resize,1*resize)
SmallRing.Mesh.Scale = Vector3.new(4.6*resize,4.6*resize,1.5*resize)
InnerSphere.Mesh.Scale = Vector3.new(-6.5*resize,-6.5*resize,-6.5*resize)
OutterSphere.Mesh.Scale = Vector3.new(6.5*resize,6.5*resize,6.5*resize)
Destruction(Pos, 3*resize)
end
for fade = 0, 1, 0.01 do
task.wait()
pcall(function()
for _, v in ShockWave do
v.Transparency = fade
end
end)
end
for _, v in ShockWave do
v:Destroy()
end
done1 = true
end)
task.spawn(function()
for resize = Size/5, Size, 1 do
task.wait()
pcall(function()
Base.Mesh.Scale = Vector3.new(2.5*resize,1*resize,4.5*resize)
TopCloud.Mesh.Scale = Vector3.new(0.75*resize,1.5*resize,1.5*resize)
MushCloud.Mesh.Scale = Vector3.new(2.5*resize,1.75*resize,3.5*resize)
Cloud1.Mesh.Scale = Vector3.new(0.5*resize,3*resize,1*resize)
Cloud2.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
Cloud3.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
PoleBase.Mesh.Scale = Vector3.new(1*resize,2*resize,2.5*resize)
PoleRing.Mesh.Scale = Vector3.new(1.2*resize,1.2*resize,1.2*resize)
Base.CFrame = CFrame.new((Pos+Vector3.new(0,0.05*resize,0)))
TopCloud.CFrame = CFrame.new((Pos+Vector3.new(0,2.7*resize,0)))
MushCloud.CFrame = CFrame.new((Pos+Vector3.new(0,2.3*resize,0)))
Cloud1.CFrame = CFrame.new((Pos+Vector3.new(0,0.75*resize,0)))
Cloud2.CFrame = CFrame.new((Pos+Vector3.new(0,1.25*resize,0)))
Cloud3.CFrame = CFrame.new((Pos+Vector3.new(0,1.7*resize,0)))
PoleBase.CFrame = CFrame.new((Pos+Vector3.new(0,0.1*resize,0)))
PoleRing.CFrame = CFrame.new((Pos+Vector3.new(0,1.3*resize,0)))
end)
end
done2 = true
end)
task.wait(2)
for y = 0.6,0,-0.0025 do
task.wait()
for _, v in Clouds do
v.Mesh.VertexColor = Vector3.new(0.9,y,0)
end
end
for r = 0.9,0.5,-0.01 do
task.wait()
for _, v in Clouds do
v.Mesh.VertexColor = Vector3.new(r, 0, 0)
end
end
for by = 0,0.5,0.005 do
task.wait()
for _, v in Clouds do
v.Mesh.VertexColor = Vector3.new(0.5,by,by)
v.Transparency = by*2
end
Base.Mesh.Scale += Vector3.new(0.1,0.1,0.1)
TopCloud.Mesh.Scale = TopCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
MushCloud.Mesh.Scale = MushCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
Cloud1.Mesh.Scale = Cloud1.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
Cloud2.Mesh.Scale = Cloud2.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
Cloud3.Mesh.Scale = Cloud3.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
PoleBase.Mesh.Scale = PoleBase.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
PoleRing.Mesh.Scale = PoleRing.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
end
done3 = true
end
Exp:Destroy()
game.Debris:AddItem(Sky, 20)
end
Explode(BasePosition)
script.Parent:Destroy()
THANK YOU FOR COMPLETELY DAMAGING MY BRAIN (no offense)
Critisicm
- Stop setting the position, just set cframe
- STOP USING SO MANY FOR LOOPS
- replace
task.delay(0, function()
with task.spawn(function()
-
:GetDescendants
exists…
- do NOT use
:remove
. instead, use :Destroy()
- MAKE YOUR CODE MORE LEGIBLE
-
:Clone()
is with a capital C
- stop using
for i, v in ipairs(table) do
IF YOU WON’T REFERENCE ‘i’
- replace
wait()
with task.wait()
-
wait(20)
and Sky:Destroy()
? no. use debris.
i could barely go further when removing unnecessary things… meaning that… it won’t work… just replace the script for future helpers