Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script does not work?

m = Instance.new(Message)
m.Name = TwoOrMore
m.Message = "There must be 2 or more players to start"
if game.Players.NumPlayers == 1
	then game.Workspace.m
for i,v in pairs(game.Players:GetChildren()) do
    v.Character.Torso.Anchored = true
elseif game.Players.NumPlayers ~= 1
	then if game.Workspace.m = true
		game.Workspace.m:Destroy()
		for i,v in pairs(game.Players:GetChildren()) do
    v.Character.Torso.Anchored = false
	end
	
end

Nothing happens?

2 comments

0

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.

0

Line 2: m.Name = "TwoOrMore"

3 answers

✓ 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!

All I could Scrap out of this...

m = Instance.new("Message", game.Workspace)
m.Name = "TwoOrMore"
m.Text = "There must be 2 or more players to start"
if game.Players.NumPlayers == 1
  then
for i,v in pairs(game.Players:GetChildren()) do
    v.Character.Torso.Anchored = true
end
elseif game.Players.NumPlayers ~= 1
   then if m ~= nil then
        m.Parent = nil
end end

Hope It works.

So

m = Instance.new("Message") 
m.Name = "TwoOrMore"
m.Text = "There must be 2 or more players to start"
if game.Players.NumPlayers == 1
then m.Parent = game.Workspace 
for i,v in pairs(game.Players:GetChildren()) do
v.Character.Torso.Anchored = true
elseif game.Players.NumPlayers ~= 1
if m ~= nil then
m.Parent = nil
for i,v in pairs(game.Players:GetChildren()) do
v.Character.Torso.Anchored = false
end end end end

3 comments

0

Nothing happens?

0

Hmm, Try added between lines 6-7 and 11-12 'if v:IsA("Player")then', and also the 'for i,v in pairs(game.Players:GetChildren())do' do 'for i, v in pairs(game.Players:GetChildren())do', those are the errors I can mainly see.

0

/\ Editing: for the 'for i,v in pairs(game.Players:GetChildren())do' loop on line 11 do 'for i, v in pairs(game.Players:GetChildren())do', also add two more end's on line 13 for the two added 'if' statements.

This discussion is preserved as it was. New answers, comments, and votes are closed.