So I made a nuke recently that should destroy everything, but here’s the problem; it doesn’t destroy everything.
What it’s ment to do is expand out and destroy everything that is inside of it. But it doesn’t. It expands, but doesn’t destroy stuff.
Here is the script I currently have:
while true do
c = game.Workspace:GetChildren()
for i =1,#c do
if ((c[i].className == "Part" or c[i].className == "TrussPart" or c[i].className == "WedgePart" or c[i].className == "Seat" or c[i].className == "VehicleSeat") and (c[i].Position - script.Parent.Position).magnitude < (script.Parent.Size.X / 2.1) - 5) then
if c[i].Locked == false then
c[i].Material = Enum.Material.CorrodedMetal
c[i].Anchored = false
c[i]:BreakJoints()
local miniboom = script.Parent.Parent.Parent.SmallBoom:Clone()
miniboom.Parent=c[i]
miniboom:Play()
game.Debris:AddItem(miniboom,1)
end
end
if (c[i].className == "Model") then
end
g = c[i]:GetChildren()
for j =1,#g do
if ((g[j].className == "Part" or g[j].className == "TrussPart" or g[j].className == "WedgePart" or g[j].className == "Seat" or g[j].className == "VehicleSeat") and g[j].Name ~= script.Parent.Name and g[j].Name ~= "Glow" and (g[j].Position - script.Parent.Position).magnitude < (script.Parent.Size.X / 2.1) - 5) then
g[j].Material = Enum.Material.CorrodedMetal
g[j].Anchored = false
g[j]:BreakJoints()
local miniboom = script.Parent.Parent.Parent.SmallBoom:Clone()
miniboom.Parent=c[i]
miniboom:Play()
game.Debris:AddItem(miniboom,1)
end
if (g[j].className == "Model") then
end
t = g[j]:GetChildren()
for s =1,#t do
if ((t[s].className == "Part" or t[s].className == "TrussPart" or t[s].className == "WedgePart" or t[s].className == "Seat" or t[s].className == "VehicleSeat") and t[s].Name ~= script.Parent.Name and t[s].Name ~= "Glow" and (t[s].Position - script.Parent.Position).magnitude < (script.Parent.Size.X / 2.1) - 5) then
t[s].Material = Enum.Material.CorrodedMetal
t[s].Anchored = false
t[s]:BreakJoints()
end
if (t[s].className == "Model") then
end
a = t[s]:GetChildren()
for z =1,#a do
if ((a[z].className == "Part" or a[z].className == "TrussPart" or a[z].className == "WedgePart" or a[z].className == "Seat" or a[z].className == "VehicleSeat") and a[z].Name ~= script.Parent.Name and a[z].Name ~= "Glow" and (a[z].Position - script.Parent.Position).magnitude < (script.Parent.Size.X / 2.1) - 5) then
a[z].Material = Enum.Material.CorrodedMetal
a[z].Anchored = false
a[z]:BreakJoints()
end
if (a[z].className == "Model") then
end
p = a[z]:GetChildren()
for l =1,#p do
if ((p[l].className == "Part" or p[l].className == "TrussPart" or p[l].className == "WedgePart" or p[l].className == "Seat" or p[l].className == "VehicleSeat") and p[l].Name ~= script.Parent.Name and p[l].Name ~= "Glow" and (p[l].Position - script.Parent.Position).magnitude < (script.Parent.Size.X / 2.1) - 5) then
p[l].Material = Enum.Material.CorrodedMetal
p[l].Anchored = false
p[l]:BreakJoints()
end
end
end
end
end
end
wait(.3)
end
“classname” should be writen like “ClassName”. Also i recommend just using the c[i]:IsA("BasePart"), because that gets every part type. It will also reduce the if statement. I hope it works.
Where would I put this in the code also? Would I do this:
for _,part in workspace:GetPartsInPart(tip) do -- but where would this go?
part.Material = Enum.Material.CorrodedMetal
part.Anchored = false
part:BreakJoints()
end
while true do
for _,part in workspace:GetPartsInPart(tip) do
part.Material = Enum.Material.CorrodedMetal
part.Anchored = false
part:BreakJoints()
end
end
uhh first…
please fix your code format, for the love of god respectfully, dont use i pair
while true do
local objects = game.Workspace:GetDescendants()
local object = next(objects)
while object do
if object:IsA("BasePart") or object:IsA("TrussPart") or object:IsA("WedgePart") or object:IsA("Seat") or object:IsA("VehicleSeat") then
local distance = (object.Position - script.Parent.Position).magnitude
if distance < (script.Parent.Size.X / 2.1) - 5 and not object.Locked then
object.Material = Enum.Material.CorrodedMetal
object.Anchored = false
object:BreakJoints()
local miniboom = script.Parent.Parent.Parent.SmallBoom:Clone()
miniboom.Parent = object
miniboom:Play()
game.Debris:AddItem(miniboom, 1)
end
end
object = next(objects, object)
end
wait(0.3)
end
local Range = 1000
for i,child in ipairs( game.Workspace:GetDescendants()) do
if object:IsA("BasePart") or object:IsA("TrussPart") or object:IsA("WedgePart") or object:IsA("Seat") or object:IsA("VehicleSeat") then
local distance = (object.Position - script.Parent.Position).magnitude
if distance <= Range and not object.Locked then
object.Material = Enum.Material.CorrodedMetal
object.Anchored = false
object:BreakJoints()
local miniboom = script.Parent.Parent.Parent.SmallBoom:Clone()
miniboom.Parent = object
miniboom:Play()
game.Debris:AddItem(miniboom, 1)
end
end
end