Help shorten the length of time this Nuke is in effect?

I need help shortening the length of time this nuke goes off in my game. Currently it lasts a whole minute and I have no idea how to script so I’m really new to these things. It currently will kill everyone for the whole minute, meaning for the amount of time it’s in effect, you will keep dying when you respawn. Heres the code (It’s really long).


local CloudID= "http://www.roblox.com/asset/?id=1095708"
local ColorTexture = "http://www.roblox.com/asset/?ID=1361097"
local RingID = "http://www.roblox.com/asset/?id=3270017"
local SphereID = "http://www.roblox.com/asset/?id=1185246"

local BasePosition = script.Parent.Position

local Size = 1000

local Exp = Instance.new("Model")
Exp.Name = "ATOMICEXPLOSION"
Exp.Parent = game.Workspace

local BasePart = Instance.new("Part")
BasePart.formFactor = 0
BasePart.TopSurface = 0
BasePart.BottomSurface = 0
BasePart.Anchored = true
BasePart.Locked = true
BasePart.CanCollide = false

local BaseMesh = Instance.new("SpecialMesh")
BaseMesh.MeshType = "FileMesh"

local CloudMesh = BaseMesh:clone()
CloudMesh.MeshId = CloudID
CloudMesh.TextureId = ColorTexture
CloudMesh.VertexColor = Vector3.new(4, 4, 0)

local RingMesh = BaseMesh:clone()
RingMesh.MeshId = RingID

local SphereMesh = BaseMesh:clone()
SphereMesh.MeshId = SphereID

local Clouds = {}
local ShockWave = {}
local Sky = script.Sky

game.Lighting.ExposureCompensation = 5
function Effects()
	script.Explode:Play()
	delay(0,function() 
		for i = 5, 1,-0.01 do
			wait()
			game.Lighting.Brightness = i
		end
	end)
end

function Destruction(Pos,Radius)
	local function Destroy(Model)
		for i ,v in ipairs(Model:getChildren()) do
			if v:isA("BasePart") then
				if (v.Position-Pos).magnitude < Radius then
					if v.Anchored == false then
						v:BreakJoints()
						v.Velocity = CFrame.new(v.Position,Pos):vectorToWorldSpace(Vector3.new(math.random(-5,5),5,1000))
						v.Material = "CorrodedMetal"
					end	
				end
			end
			if #v:getChildren() > 0 then
				Destroy(v)
			end
		end
	end
	Destroy(game.Workspace)
end
function Explode(Pos)

local Base = BasePart:clone()
Base.Position = Pos
	
local Mesh = CloudMesh:clone()
Mesh.Parent = Base 
Mesh.Scale = Vector3.new(2.5,1,4.5)

local PoleBase = BasePart:clone()
PoleBase.Position = 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.Position = 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.Position = 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.Position = 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.Position = 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.Position = Pos+Vector3.new(0,2.3,0)
	
local MushMesh = CloudMesh:clone() -- lol
MushMesh.Scale = Vector3.new(2.5,1.75,3.5)
MushMesh.Parent = MushCloud

local TopCloud = BasePart:clone()
TopCloud.Position = 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.Position = 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.Position = 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.Position = Pos
InnerSphere.BrickColor = BrickColor.new("Bright orange")
InnerSphere.Transparency = 1

local InnerSphereMesh = SphereMesh:clone()	
InnerSphereMesh.Scale = Vector3.new(-6.5,-6.5,-6.5)
InnerSphereMesh.Parent = InnerSphere
	
local OutterSphere = BasePart:clone()
OutterSphere.Position = Pos
OutterSphere.BrickColor = BrickColor.new("Bright orange")
OutterSphere.Transparency = 1

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 i , v in ipairs(ShockWave) do
		v.Parent = Exp
	end
	for i , v in ipairs(Clouds) do
		v.Parent = Exp
	end
	Effects()
	delay(0,function()
		for resize = Size/2.5, Size*3, 2 do
			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
			wait()
			pcall(function()
				for i ,v in ipairs(ShockWave) do
					v.Transparency = fade
				end
			end)
		end
		for i ,v in ipairs(ShockWave) do
			v:Remove()
		end
		done1 = true
	end)
	delay(0,function()
		for resize = Size/5, Size, 1 do
			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.Position = Pos+Vector3.new(0,0.05*resize,0)
				TopCloud.Position = Pos+Vector3.new(0,2.7*resize,0)
				MushCloud.Position = Pos+Vector3.new(0,2.3*resize,0)
				Cloud1.Position = Pos+Vector3.new(0,0.75*resize,0)
				Cloud2.Position = Pos+Vector3.new(0,1.25*resize,0)
				Cloud3.Position = Pos+Vector3.new(0,1.7*resize,0)
				PoleBase.Position = Pos+Vector3.new(0,0.1*resize,0)
				PoleRing.Position = Pos+Vector3.new(0,1.3*resize,0)
			end)
		end
		done2 = true
	end)
	wait(2)
	for y = 0.6,0,-0.0025 do
		wait()
		for i , v in ipairs(Clouds) do
			v.Mesh.VertexColor = Vector3.new(4, 4, 0)
		end
	end
	for r = 0.9,0.5,-0.01 do
		wait()
		for i , v in ipairs(Clouds) do
			v.Mesh.VertexColor = Vector3.new(4, 4, 0)
		end
	end
	for by = 0,0.5,0.005 do
		wait()
		for i , v in ipairs(Clouds) do
			v.Mesh.VertexColor = Vector3.new(4, 4, 0)
			v.Transparency = by*2
		end
		Base.Mesh.Scale = 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
	while true do wait(1) if done1 and done2 and done3 then break end end
	Exp:remove()
	wait(2)
	Sky:remove()
end


	

Explode(BasePosition)
game.Lighting.ExposureCompensation = 4
wait()
game.Lighting.ExposureCompensation = 3
wait()
game.Lighting.ExposureCompensation = 2
wait()
game.Lighting.ExposureCompensation = 1
wait()
game.Lighting.ExposureCompensation = 0
wait()
script.Parent:remove()
1 Like

This is a very very old script. That is besides the point though. The script has no built-in configuration to set the time of the nuke explosion. The amount the explosion last is hardcoded in all the for loops the script uses. However, this script uses a lot of loops and I’m not really feeling like editing it to have a time variable and also be up to modern luau usage. If someone else hasn’t responded to you by tomorrow then I’ll edit the script for you to work with a time variable as well as use better syntax.

2 Likes

Okay. Yea I’m new to scripting, I just started learning about it this week so I wasn’t sure. I couldn’t find anything other than that script. But if you are willing to do that then thank you so much, I don’t wanna be a burden lol

Alright, as promised, here’s the revised script. A few things you should know though, because this is a very old script that used a lot of loops instead of TweenService | Roblox Creator Documentation or checking the size and time with RunService | Roblox Creator Documentation, the results for the amount of time the explosion last are inaccurate due to this. Currently the script works as I pasted it in, but I have no idea how well it will work when you mess around with the settings. So just expect that it might not last as long as you want it too. Currently it only last 37 seconds even though I have it set to last 60 seconds.

local CloudID= "http://www.roblox.com/asset/?id=1095708"
local ColorTexture = "http://www.roblox.com/asset/?ID=1361097"
local RingID = "http://www.roblox.com/asset/?id=3270017"
local SphereID = "http://www.roblox.com/asset/?id=1185246"

local BasePosition = script.Parent.Position

-- Settings: --
local Size = 1000 -- The size the nuke grows to
local ExplosionTime = 60 -- The time in seconds the explosion last
local Exposure = 1 -- the brightness the nukes creates. 0 is the games default exposure.
---------------

local Exp = Instance.new("Model")
Exp.Name = "ATOMICEXPLOSION"
Exp.Parent = game.Workspace

local BasePart = Instance.new("Part")
BasePart.formFactor = 0
BasePart.TopSurface = 0
BasePart.BottomSurface = 0
BasePart.Anchored = true
BasePart.Locked = true
BasePart.CanCollide = false

local BaseMesh = Instance.new("SpecialMesh")
BaseMesh.MeshType = "FileMesh"

local CloudMesh = BaseMesh:Clone()
CloudMesh.MeshId = CloudID
CloudMesh.TextureId = ColorTexture
CloudMesh.VertexColor = Vector3.new(4, 4, 0)

local RingMesh = BaseMesh:Clone()
RingMesh.MeshId = RingID

local SphereMesh = BaseMesh:Clone()
SphereMesh.MeshId = SphereID

local Clouds = {}
local ShockWave = {}
local Sky = script.Sky

local function WaitTime(num1,num2,iter,percentage)
	local timeWait

	if iter < 0 then
		timeWait = (ExplosionTime/((num1-num2)/iter))*percentage
	else
		timeWait = (ExplosionTime/((num2-num1)/iter))*percentage
	end

	return timeWait
end

function Effects()
	script.Explode:Play()

	if Exposure <= 0 then return end

	spawn(function() 
		for i = Exposure, 1,-0.01 do
			game.Lighting.Brightness = i
			game.Lighting.ExposureCompensation = i
			wait(i/ExplosionTime)
		end
	end)
end

function Destruction(Pos,Radius)
	local function Destroy(Model)
		for i ,v in ipairs(Model:GetChildren()) do
			if v:isA("BasePart") then
				if (v.Position-Pos).magnitude < Radius then
					if v.Anchored == false then
						v:BreakJoints()
						v.Velocity = CFrame.new(v.Position,Pos):VectorToWorldSpace(Vector3.new(math.random(-5,5),5,1000))
						v.Material = "CorrodedMetal"
					end	
				end
			end
			if #v:GetChildren() > 0 then
				Destroy(v)
			end
		end
	end
	Destroy(game.Workspace)
end

function Explode(Pos)

	local Base = BasePart:Clone()
	Base.Position = Pos

	local Mesh = CloudMesh:Clone()
	Mesh.Parent = Base 
	Mesh.Scale = Vector3.new(2.5,1,4.5)

	local PoleBase = BasePart:Clone()
	PoleBase.Position = 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.Position = 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.Position = 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.Position = 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.Position = 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.Position = Pos+Vector3.new(0,2.3,0)

	local MushMesh = CloudMesh:Clone() -- lol
	MushMesh.Scale = Vector3.new(2.5,1.75,3.5)
	MushMesh.Parent = MushCloud

	local TopCloud = BasePart:Clone()
	TopCloud.Position = 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.Position = 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.Position = 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.Position = Pos
	InnerSphere.BrickColor = BrickColor.new("Bright orange")
	InnerSphere.Transparency = 1

	local InnerSphereMesh = SphereMesh:Clone()	
	InnerSphereMesh.Scale = Vector3.new(-6.5,-6.5,-6.5)
	InnerSphereMesh.Parent = InnerSphere

	local OutterSphere = BasePart:Clone()
	OutterSphere.Position = Pos
	OutterSphere.BrickColor = BrickColor.new("Bright orange")
	OutterSphere.Transparency = 1

	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 i , v in ipairs(ShockWave) do
		v.Parent = Exp
	end
	for i , v in ipairs(Clouds) do
		v.Parent = Exp
	end

	Effects()

	spawn(function()
		local timeWait = WaitTime(Size/2.5, Size*3, 4, 0.1)

		for resize = Size/2.5, Size*3, 4 do
			wait(timeWait)
			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)

			for i ,v in ipairs(ShockWave) do
				v.Transparency = resize/(Size*3)
			end
		end

		for i ,v in ipairs(ShockWave) do
			v:Destroy()
		end
		done1 = true
	end)

	spawn(function()
		local timeWait = WaitTime(Size/5, Size, 1, 1)
		
		for resize = (Size*0.2), Size, 2 do
			wait(timeWait)
			Base.Mesh.Scale = Vector3.new(1.8*resize,1*resize,3.25*resize)
			TopCloud.Mesh.Scale = Vector3.new(0.75*resize,1.75*resize,1.5*resize)
			MushCloud.Mesh.Scale = Vector3.new(2.5*resize,2*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.Position = Pos+Vector3.new(0,0.05*resize,0)
			TopCloud.Position = Pos+Vector3.new(0,2.7*resize,0)
			MushCloud.Position = Pos+Vector3.new(0,2.3*resize,0)
			Cloud1.Position = Pos+Vector3.new(0,0.75*resize,0)
			Cloud2.Position = Pos+Vector3.new(0,1.25*resize,0)
			Cloud3.Position = Pos+Vector3.new(0,1.7*resize,0)
			PoleBase.Position = Pos+Vector3.new(0,0.1*resize,0)
			PoleRing.Position = Pos+Vector3.new(0,1.3*resize,0)

			if resize >= (0.8*Size) then
				for i , v in ipairs(Clouds) do
					v.Transparency = (resize-(0.8*Size))/(0.2*Size)
				end
			end
		end
		done2 = true
	end)
	
	while true do
		wait(0.25)
		if done1 and done2 then
			break
		end
	end

	Exp:Destroy()
	Sky:Destroy()
end



local TimeCheck = DateTime.now().UnixTimestampMillis
Explode(BasePosition)
print("Time Elapsed: ",(DateTime.now().UnixTimestampMillis - TimeCheck)/1000)
1 Like