- Basically I want that when someone wins in my game confetti are enabled for like 10 sec. To do this, I put a transparent part above the spawn points (where the players get teleported after the round ends; a round ends when someone wins by touching a part) that contains 7 particle emitters(confetti). Note that by default I set in the confetti properties enabled as false.
This is the script (called ‘Main’):
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local vals = ReplicatedStorage.vals
local Sound1 = script.Parent.TimeSound
local Sound2 = script.Parent.Sound2
local s = script.Stat
local blocco = script.Parent.BloccoPartenza
--//Controls
local timeRemaining = 0
--//Tables
local timeValues = {
[3] = "Ready",
[2] = "Steady",
[1] = "Set",
[0] = "Go!",
}
--//Loops
while true do
--//Intermission
timeRemaining = 30
repeat
timeRemaining -= 1
s.Value = "Intermission... ".. timeRemaining
task.wait(1)
until timeRemaining == 0
s.Value = "Game starting!"
task.wait(2)
blocco.CanCollide = true
local mapselect = ReplicatedStorage.Games:GetChildren()
local choose = Random.new():NextInteger(1, #mapselect)
local curnum = 0
for i = 1, #mapselect do
curnum += 1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = "We'll be playing "..mapselect[i].Name
end
end
task.wait(3)
--//Start game
local plrs = Players:GetPlayers()
for i, player in ipairs(Players:GetPlayers()) do
pcall(player.LoadCharacter, player)
task.defer(function()
local randomNumber = Random.new():NextInteger(1, 32)
player.Character.Head.CFrame = CFrame.new(workspace.Teleports["Part".. randomNumber].Position)
player.Character.Parent = workspace.Ingame
end)
end
timeRemaining = 4
repeat
timeRemaining -= 1
s.Value = timeValues[timeRemaining]
if s.Value == "Go!" then
blocco.CanCollide = false
end
if s.Value == "Ready" then
Sound2:Play()
end
task.wait(1)
until timeRemaining == 0
timeRemaining = 120
repeat
timeRemaining -= 1
s.Value = timeRemaining.." seconds left"
if timeRemaining == 10 then
Sound1:Play()
end
task.wait(1)
until timeRemaining == 0 or vals.Winner.Value ~= "" or #workspace.Ingame:GetChildren() == 0
--//End game
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
if #workspace.Ingame:GetChildren() == 0 then
s.Value = "No one has won!"
end
else
s.Value = "No one has won!"
end
if s.Value == vals.Winner.Value.. " has won!" then
for _, conf in workspace.ConfettiGiver:GetChildren() do
conf.Enabled = true
task.delay(10,function()
conf.Enabled = false
end)
end
end
if vals.Winner.Value =="" then
Sound1:Stop()
end
task.wait(3)
local ingame = workspace.Ingame:GetChildren()
for i = 1, #ingame do
local player = Players:GetPlayerFromCharacter(ingame[i])
pcall(player.LoadCharacter, player)
end
workspace[curmap]:Destroy()
end
The part in the Main script where I try to enable confetti whenever someone wins:
if s.Value == vals.Winner.Value.. " has won!" then
for _, conf in workspace.ConfettiGiver:GetChildren() do
conf.Enabled = true
task.delay(10,function()
conf.Enabled = false
end)
end
end
Screen
Despite the script seemed okay to me, it doesn’t work and I cant figure out why (I dont see any error in the output)
i have no experience yet and i am a new roblox studio user so please be patient. Also thanks for your attention, any help is appreciated