Hello!
I'm making a round system with player added event. To avoid it to work as two scripts when two players are playing, I used the :Disconnect() function. The matter is that it works only for the first player who joined. Can someone help me?
Here's the script. To start another round, the script has another script called "Reset" that disables and enable the script to start other round, but with that function it doesn't start a new round.
local onPlayerAddedConnection
onPlayerAddedConnection = game.Players.PlayerAdded:Connect(function(plr)
onPlayerAddedConnection:Disconnect()
local Player = game.Players:WaitForChild(plr.Name)
local GUI = Player.PlayerGui:WaitForChild("RoundsGUI")
local function toround()
GUI.Status.Text = "Status: In round"
GUI.Sixty.Disabled = true
GUI.ThreeSixty.Disabled = false
game.Workspace.Rift.Rift.Rift.TimePosition = 9.5
game.Workspace.Rift.Rift.Rift:Play()
game.Workspace.Rift.Rift.Transparency = 0
Player.Character.HumanoidRootPart.CFrame = game.Workspace.Rift.Rift.CFrame
wait(5)
game.Workspace.Rift.Rift.Transparency = 1
end
local function tolobby()
if Player.Character:FindFirstChild("[NON VIP] Laser blaster") then
Player.Character["[NON VIP] Laser blaster"]:Destroy()
end
if Player.Character:FindFirstChild("[DROP] Laser blaster") then
Player.Character["[DROP] Laser blaster"]:Destroy()
end
if Player.Character:FindFirstChild("[VIP] Laser blaster") then
Player.Character["[VIP] Laser blaster"]:Destroy()
end
if Player.Character:FindFirstChild("[MYTHIC] Laser blaster") then
Player.Character["[MYTHIC] Laser blaster"]:Destroy()
end
if Player.Character:FindFirstChild("[NON VIP] Sword") then
Player.Character["[NON VIP] Sword"]:Destroy()
end
if Player.Character:FindFirstChild("[DROP] Sword") then
Player.Character["[DROP] Sword"]:Destroy()
end
if Player.Character:FindFirstChild("[VIP] Sword") then
Player.Character["[VIP] Sword"]:Destroy()
end
if Player.Character:FindFirstChild("[MYTHIC] Sword") then
Player.Character["[MYTHIC] Sword"]:Destroy()
end
if Player.Character:FindFirstChild("[NON VIP] Med kit") then
Player.Character["[NON VIP] Med kit"]:Destroy()
end
if Player.Character:FindFirstChild("[DROP] Med kit") then
Player.Character["[DROP] Med kit"]:Destroy()
end
if Player.Character:FindFirstChild("[VIP] Med kit") then
Player.Character["[VIP] Med kit"]:Destroy()
end
if Player.Character:FindFirstChild("[NON VIP] Parachute") then
Player.Character["[NON VIP] Parachute"]:Destroy()
end
if game.Workspace:FindFirstChild("Drop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("Drop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("Drop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("MythicDrop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("MythicDrop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("MythicDrop") then
game.Workspace.Drop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
if game.Workspace:FindFirstChild("ImmediateDrop") then
game.Workspace.ImmediateDrop:Destroy()
end
Player.Character.MedKits.Disabled = true
GUI.RoundMode.Text = "Gamemode: "
GUI.Status.Text = "Status: In lobby"
GUI.ThreeSixty.Disabled = true
GUI.Sixty.Disabled = false
Player.Backpack:ClearAllChildren()
Player.Character.Humanoid.Health = 100
game.Workspace.Lobby.LobbyRift.Rift.Rift.TimePosition = 9.5
game.Workspace.Lobby.LobbyRift.Rift.Rift:Play()
game.Workspace.Lobby.LobbyRift.Rift.Transparency = 0
Player.Character.HumanoidRootPart.CFrame = game.Workspace.Lobby.LobbyRift.Rift.CFrame
wait(5)
game.Workspace.Lobby.LobbyRift.Rift.Transparency = 1
end
local function startdrop()
game.ServerStorage.Drop:Clone().Parent = game.Workspace
game.ServerStorage.Drop:Clone().Parent = game.Workspace
game.ServerStorage.Drop:Clone().Parent = game.Workspace
end
local function startdropmode()
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
game.ServerStorage.ImmediateDrop:Clone().Parent = game.Workspace
end
local function mythicdrops()
game.ServerStorage.MythicDrop:Clone().Parent = game.Workspace
game.ServerStorage.MythicDrop:Clone().Parent = game.Workspace
game.ServerStorage.MythicDrop:Clone().Parent = game.Workspace
end
wait(2)
tolobby()
local Value = script.Value.Value
local Gamemodes = game.ServerStorage.Gamemodes
--Start cycle
Value = math.random(1,2)
if Value == 1 then
print(Value)
wait(55)
GUI.RoundMode.Text = "Gamemode: Only MYTHIC weapons"
Gamemodes.OnlyMythicWeapons["[NON VIP] Parachute"]:Clone().Parent = Player.Backpack
Gamemodes.OnlyMythicWeapons["[NON VIP] Med kit"]:Clone().Parent = Player.Backpack
Gamemodes.OnlyMythicWeapons["[MYTHIC] Laser blaster"]:Clone().Parent = Player.Backpack
Gamemodes.OnlyMythicWeapons["[MYTHIC] Sword"]:Clone().Parent = Player.Backpack
toround()
game.ServerStorage.Zombies:Clone().Parent = game.Workspace
wait(360)
game.Workspace.Zombies:Destroy()
Player.PlayerGui.RoundOver.Text1.TransparencyScript.Disabled = false
Player.PlayerGui.RoundOver.Text2.TransparencyScript.Disabled = false
Player.PlayerGui.RoundOver.Text3.TransparencyScript.Disabled = false
Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + 1
Value = 0
script.Reset.Disabled = false
end
if Value == 2 then
print(Value)
wait(60)
GUI.RoundMode.Text = "Gamemode: Classic gameplay"
startdrop()
Gamemodes.ClassicMode["[NON VIP] Laser blaster"]:Clone().Parent = Player.Backpack
Gamemodes.ClassicMode["[NON VIP] Sword"]:Clone().Parent = Player.Backpack
Gamemodes.ClassicMode["[NON VIP] Parachute"]:Clone().Parent = Player.Backpack
Gamemodes.ClassicMode["[NON VIP] Med kit"]:Clone().Parent = Player.Backpack
Player.Character.MedKits.Disabled = false
toround()
game.ServerStorage.Zombies:Clone().Parent = game.Workspace
wait(360)
game.Workspace.Zombies:Destroy()
Player.PlayerGui.RoundOver.Text1.TransparencyScript.Disabled = false
Player.PlayerGui.RoundOver.Text2.TransparencyScript.Disabled = false
Player.PlayerGui.RoundOver.Text3.TransparencyScript.Disabled = false
Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + 1
Value = 0
script.Reset.Disabled = false
end
end)
