✓ Accepted answer
I had done the script in two different functions and events, I think it should work now;
local m = Instance.new("Message")
m.Name = "TwoOrMore"
local Player = 0
game.Players.PlayerAdded:connect(function()
if game.Players.NumPlayers == 1 or game.Players.NumPlayers <=1 then
m.Parent = game.Workspace
Player = Player + 1
m.Text = "There must be "..Player.." more player(s) for the game to start."
for i,v in pairs(game.Players:GetChildren()) do
if v:IsA("Player")then
repeat wait(0)until v and v.Character and v:GetMouse()and v.Character:FindFirstChild("Torso")and v.Character:FindFirstChild("Humanoid")
v.Character.Torso.Anchored = true
v.Character.Humanoid.Name = "humanoid"
elseif game.Players.NumPlayers >= 1 then
if m ~= nil then
m.Parent = nil
Player = Player - 1
for i, v in pairs(game.Players:GetChildren()) do
if v:IsA("Player")then
repeat wait(0)until v and v.Character and v:GetMouse()and v.Character:FindFirstChild("Torso")and v.Character:FindFirstChild("humanoid")
v.Character.Torso.Anchored = false
v.Character.humanoid.Name = "Humanoid"
end end end end end end end)
game.Players.PlayerRemoving:connect(function()
if game.Players.NumPlayers == 1 or game.Players.NumPlayers <=1 then
m.Parent = game.Workspace
Player = Player + 1
m.Text = "There must be "..Player.." more player(s) for the game to start."
for i,v in pairs(game.Players:GetChildren()) do
if v:IsA("Player")then
repeat wait(0)until v and v.Character and v:GetMouse()and v.Character:FindFirstChild("Torso")and v.Character:FindFirstChild("Humanoid")
v.Character.Torso.Anchored = true
v.Character.Humanoid.Name = "humanoid"
elseif game.Players.NumPlayers >= 1 then
if m ~= nil then
m.Parent = nil
Player = Player - 1
for i, v in pairs(game.Players:GetChildren()) do
if v:IsA("Player")then
repeat wait(0)until v and v.Character and v:GetMouse()and v.Character:FindFirstChild("Torso")and v.Character:FindFirstChild("humanoid")
v.Character.Torso.Anchored = false
v.Character.humanoid.Name = "Humanoid"
end end end end end end end)
I hope this helps!
2 comments
Line 1: m = Instance.new("Message") Line 3: m.Text = "There must be 2 or more players to start" Line 5: then m.Parent = game.Workspace Line 9: if m ~= nil then Line 10: m.Parent = nil Line 13: end end end end --Remove that empty space at line 14 and remove the end at line 15.
Line 2: m.Name = "TwoOrMore"