How To Make Acid Rain Fall During Round

Hello, I’m trying to better understand scripting by making a little game to test my skills. I have these 2 scripts (shown below) that I have created, I was wondering how I could make the Acid Rain Script trigger/play every time a new round starts.

Acid Rain Script

local Debris = game:GetService("Debris")
local beingdamaged = true

while true do
	local Rain = Instance.new("Part", workspace)
	local SphereMesh = Instance.new("SpecialMesh")
	local randomX = math.random(-200,200)
	local randomZ = math.random(-200,200)
	
	SphereMesh.MeshType = "Sphere"
	
	SphereMesh.Parent = Rain
	
	Rain.Color = Color3.fromRGB(85, 255, 0)
	
	Rain.Material = "Neon"
	
	Rain.Size = Vector3.new(1,1,1)
	
	Rain.Position = Vector3.new(randomX, 50, randomZ)
	
	Rain.Touched:Connect(function(touchRain)
		local humanoid = touchRain.Parent:FindFirstChild("Humanoid")
		beingdamaged = false
		if humanoid and beingdamaged == false then
			humanoid.Health = humanoid.Health - 1
			beingdamaged = true
			Debris:AddItem(Rain,0.1)
		end
	end)
	
	wait()
	
	Debris:AddItem(Rain,5)
end

Round Script

local Lobby = game.Workspace.Lobby
local Maps = game.ReplicatedStorage.Maps:GetChildren()
local Status = game.ReplicatedStorage.Status

--Game Loop

while true do
	
	--Intermission
	
	for i = 10, 0, -1 do
		Status.Value = "Intermission:	"..i
		task.wait(1)
	end
	
	--Map Selector
	
	local ChosenMap = Maps[math.random(1, #Maps)]
	local ClonedMap = ChosenMap:Clone()
	
	ClonedMap.Parent = game.Workspace
	Status.Value = "Map Selected:	"..ClonedMap.Name
	
	task.wait(3)
	
	--Teleport players to Map
	
	for i, Player in pairs(game.Players:GetPlayers()) do
		
		local Character = Player.Character
		
		if Character then
			
			local HRT = Character.HumanoidRootPart
			
			HRT.CFrame = ClonedMap.TeleportPart.CFrame
		end
	end
	
	-- Game Time
	
	for i = 10,0, -1 do
		Status.Value = "Time Left:	"..i
		task.wait(1)
	end
	
	Status.Value = "Round Over"
	task.wait(2)
	
	-- Teleports players back to lobby
	
	for i, Player in pairs(game.Players:GetPlayers()) do
		
		local Character = Player.Character
		
		if Character then
			
			local HRT = Character.HumanoidRootPart
			
			HRT.CFrame = Lobby.TeleportPart.CFrame
		end
	end
	
	-- Destroy Map
	
	ClonedMap:Destroy()
end
1 Like

If you want your script to stop when intermission starts you can just disable your script

For example: If your script is in Workspace and is called acid rain, you can do this:

local Script =  game.Workspace["acid rain"] --This is the name of the script (example)


local Lobby = game.Workspace.Lobby
local Maps = game.ReplicatedStorage.Maps:GetChildren()
local Status = game.ReplicatedStorage.Status

--Game Loop

while true do
	
	--Intermission
	
	for i = 10, 0, -1 do
		Status.Value = "Intermission:	"..i
		task.wait(1)
	end
	
	--Map Selector
	
	local ChosenMap = Maps[math.random(1, #Maps)]
	local ClonedMap = ChosenMap:Clone()
	
	ClonedMap.Parent = game.Workspace
	Status.Value = "Map Selected:	"..ClonedMap.Name
	
	task.wait(3)
	Script.Disabled = false ---////////////////////Makes the script active

	--Teleport players to Map
	
	for i, Player in pairs(game.Players:GetPlayers()) do
		
		local Character = Player.Character
		
		if Character then
			
			local HRT = Character.HumanoidRootPart
			
			HRT.CFrame = ClonedMap.TeleportPart.CFrame
		end
	end
	
	-- Game Time
	
	for i = 10,0, -1 do
		Status.Value = "Time Left:	"..i
		task.wait(1)
	end
	
	Status.Value = "Round Over"
        Script.Disabled = True---////////////////////Makes the script stop
	task.wait(2)
	
	-- Teleports players back to lobby
	
	for i, Player in pairs(game.Players:GetPlayers()) do
		
		local Character = Player.Character
		
		if Character then
			
			local HRT = Character.HumanoidRootPart
			
			HRT.CFrame = Lobby.TeleportPart.CFrame
		end
	end
	
	-- Destroy Map
	
	ClonedMap:Destroy()
endo aquí

If it is not how you want it, you can tell me and I will look for another solution for what you want to achieve :smile:

1 Like