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