generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Help please

Previous Thread :: Next Thread 
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
13 Feb 2012 10:08 PM
local h = Instance.new("Hint",Workspace)
local isOn = true

if game.Players.NumPlayers < 2 then
isOn = false
h.Text = "2 or more Players needed to play. Invite some friends!!!"
end

if game.Players.NumPlayers >= 2 then
isOn = true
end

while isOn == true do
h.Text = "There is more than 2 players in the server. Starting new game."
wait(1)
h.Text = "There is more than 2 players in the server. Starting new game.."
wait(1)
h.Text = "There is more than 2 players in the server. Starting new game..."
wait(5)
p = game.Players:GetChildren()
for i = 1,#p do
p[i].Character.Torso.CFrame = CFrame.new(0,0,0)
end
for x = 10, 0, -1 do
h.Text = ""..x..""
wait(1)
end
local b = Instance.new("Part",Workspace)
b.Size = Vector3.new(50,50,50)
local p = Instance.new("Part",Workspace)
p.Size = Vector3.new(50,50,50)
function onTouch(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if (human ~= nil) then
isOn = false
wait(1)
b:Destroy()
p:Destroy()
isOn = true
pl = game.Players:GetChildren()
for m = 1,#pl do
pl[m].Charater.Torso.CFrame = Vector3.new(0,0,0)
end
end
end
end

game.Workspace.TouchMe.Touched:connect(onTouch)


It doesnt work. If there are more than 2 players in the server the script doesnt start running. Can anybody please help?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
13 Feb 2012 10:15 PM
That's because the code only runs once. And since right at the beginning the Players < 2 then the while loop doesn't run. Sure that's it, though, I am tired and going to bed :P
Report Abuse
mage11561 is not online. mage11561
Joined: 03 Sep 2008
Total Posts: 13217
13 Feb 2012 10:16 PM
Use PlayerAdded.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
13 Feb 2012 10:24 PM
Try this.


    local h = Instance.new("Hint", Workspace)
    h.Text = "2 or more players are needed to play. Invite some friends!!!"
    local plrs = #game.Players:GetPlayers()
    
    function updateGame()
        if plrs < 2 then
            h.Text = "2 or more Players needed to play. Invite some friends!!!"
        else
            for i = 1, 3 do
                h.Text = "There are more than 2 players in the server. Starting new game"..string.rep(".", i)
            end
            
            for i, v in pairs(game.Players:GetChildren()) do
                v.Character:MoveTo(Vector3.new(0,0,0))
            end
            
            for x = 10, 1, -1 do
                h.text = x
                wait(1)
            end
            
            local b = Instance.new("Part",Workspace)
            b.Size = Vector3.new(50,50,50)
            
            local p = Instance.new("Part",Workspace)
            p.Size = Vector3.new(50,50,50)
            
            game.Workspace.TouchMe.Touched:connect(function(h)
                h = game.Players:GetPlayerFromCharacter(h.Parent)
                if h == nil then return end
                p:Destroy()
                b:Destroy()
                for i, v in pairs(game.Players:GetChildren()) do
                    v.Character:MoveTo(Vector3.new(0,0,0))
                end
            end)
        end
    end
    
    function updatePlrCnt()
        plrs = #game.Players:GetPlayers()
        updateGame()
    end
    game.Players.PlayerAdded:connect(updatePlrCnt)
    game.Players.PlayerRemoving:connect(updatePlrCnt)


----------
    ~pwnedu46, wiki writer~
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
13 Feb 2012 10:25 PM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can you show me how and where I should put it?
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
13 Feb 2012 10:26 PM
Forget that post above. I was sapose to ask the person before you
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
13 Feb 2012 10:50 PM
@pwnedu46

the connection lines are both the same. which is which?
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
14 Feb 2012 03:36 PM
The connections are similar, but not the same. They both call the same function, but are fired by different events. The logic applies in both situations, so it's easier and more effective to have the whole thing handled by one function.


----------
    ~pwnedu46, wiki writer~
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
15 Feb 2012 09:33 PM
How would you make this so it resets when all of the players have died?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image