Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This script does not work?

Asked by
Wubblu 20
10 years ago
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?

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. TheeDeathCaster 2368 — 10y
0
Line 2: m.Name = "TwoOrMore" TheeDeathCaster 2368 — 10y

3 answers

Log in to vote
1
Answered by 10 years ago

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!

Ad
Log in to vote
1
Answered by
IcyEvil 260 Moderation Voter
10 years ago

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.

Log in to vote
0
Answered by
Wubblu 20
10 years ago

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
0
Nothing happens? Wubblu 20 — 10y
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. TheeDeathCaster 2368 — 10y
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. TheeDeathCaster 2368 — 10y

Answer this question