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

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

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

2 comments

0

Add between 4 and 5, 'if v:IsA("Player") then', then add two more ends at line 7.

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'.

1 answer

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

1 comment

0

Woops wait(10)

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