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

How would I make the game check this script every 10 secs?

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

So I want to make the game check if there is more then 1 player every 10 seconds so that if there were more then one but then they left and there was one left it would freeze their torso.

Also how do I make this script work?

Playing = false
wait(5)
if game.Players.NumPlayers ~= 1 then
    for i,v in pairs(game.Players:GetChildren()) do
    v.Character.Torso.CFrame = CFrame.new(-551.6, 18.699, 164.8)
Playing = true
end
0
Add between 4 and 5, 'if v:IsA("Player") then', then add two more ends at line 7. TheeDeathCaster 2368 — 10y
0
/\ Adding on: For the second script. The first script uses the PlayerAdded event for when a Player join, but I'd probly change line 18 to 'Player = 0'. TheeDeathCaster 2368 — 10y

1 answer

Log in to vote
-1
Answered by
iLegitus 130
10 years ago

Just copy this instead of the previous one

while true do
wait()
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)

wait(3)
end
0
Woops wait(10) iLegitus 130 — 10y
Ad

Answer this question