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
 

Re: NumPlayers [Need help with this gameplay script]

Previous Thread :: Next Thread 
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 03:52 PM
Well, I've created myself a Build to Survive Zombies gameplay script, assigning the Models, Instances and GUIs.

I tried adding in the NumPlayers function but it did not work in my script so I was wondering if you would like to fix it for me. I will show you my script, this script works.

------------------

gui = script.GuiText.Value
zdoor1 = game.Workspace.Doors.ZombieDoor1
zdoor2 = game.Workspace.Doors.ZombieDoor2
zdoor3 = game.Workspace.Doors.ZombieDoor3
zdoor4 = game.Workspace.Doors.ZombieDoor4
secondsa = script.Seconds1.Value
secondsb = script.Seconds2.Value
secondsc = script.Seconds3.Value
m1 = game.Workspace.HorrorMusic
m2 = game.Workspace.Applause

while true do

for i = 1,secondsa do
wait(1)
script.GuiText.Value = "Buy weapons and build some defense! Be armed and ready, you have "..secondsa - i.." seconds left!"
wait()
end

m1:play(looped)

for i = 1,secondsb do
wait(1)
zdoor1.Transparency = 1
zdoor1.CanCollide = false
zdoor2.Transparency = 1
zdoor2.CanCollide = false
zdoor3.Transparency = 1
zdoor3.CanCollide = false
zdoor4.Transparency = 1
zdoor4.CanCollide = false
script.GuiText.Value = "The Zombies are released! Go kill them! you have "..secondsb - i.." seconds left!"
if i == secondsb then
zdoor1.Transparency = 0
zdoor1.CanCollide = true
zdoor2.Transparency = 0
zdoor2.CanCollide = true
zdoor3.Transparency = 0
zdoor3.CanCollide = true
zdoor4.Transparency = 0
zdoor4.CanCollide = true
end
end

for i = 1,secondsc do
wait(1)
script.GuiText.Value = "Kill the remaning zombies! "..secondsc - i.." seconds left until the round is over!"
wait()
end

m1:stop()

m2:play()

script.GuiText.Value = "Well done all of you guys!"
wait(10)
m2:stop()
end

Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 03:58 PM
Actually, I wasn't being specific here.

I want it to actually find 2 players in a server before the game starts, also if there is less than 2 players then the game would stop and have to wait for another player to join the game.
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:12 PM
Anyone?
Report Abuse
rodytenhoopen is not online. rodytenhoopen
Joined: 12 Nov 2010
Total Posts: 59
31 May 2014 04:13 PM
alreadystarted = false

game.Players.PlayerAdded:connect(function(Player)
if game.Players.NumPlayers >= 2 and alreadystarted == false then
alreadystarted = true
(YOUR SCRIPT HERE)
end
end
Report Abuse
rodytenhoopen is not online. rodytenhoopen
Joined: 12 Nov 2010
Total Posts: 59
31 May 2014 04:15 PM
Oh and it's with a ) on the last end
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:21 PM
Okay, I'll try it out.
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:25 PM
How am I suppose to make the script let the players know if they need 1 more person in the game? I need to add in the 'script.GuiText.Value = ""' bit.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
31 May 2014 04:30 PM
"secondsa = script.Seconds1.Value
secondsb = script.Seconds2.Value
secondsc = script.Seconds3.Value"
Is Value a Value i,e StringValue, NumberValue, if so, you can't define a Property like .Name etc.
you have to do:
secondsa = script.Seconds1
secondsb = script.Seconds2
secondsc = script.Seconds3

if secondsa.Value == 0 then
-- do stuff
end
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:35 PM
@Youssef

Seconds1, 2 and 3 are both NumberValues. I assigned them as that.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
31 May 2014 04:36 PM
You have to do it like this:

secondsa = script.Seconds1
secondsb = script.Seconds2
secondsc = script.Seconds3

if secondsa.Value == 0 then
-- do stuff
end
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:39 PM
I know but I added in the 'Value' next to them just incase. At least the script works though.

The GuiText is also the StringValue.

And still I need to know how I add in the NumPlayers function, putting in 2 players to start a game and less than 2 players to stop the game.
Report Abuse
rodytenhoopen is not online. rodytenhoopen
Joined: 12 Nov 2010
Total Posts: 59
31 May 2014 04:44 PM
game.Players.PlayerRemoving:connect(function(Player) -- Not sure abbout PlayerRemoving
if game.Players.NumPlayers <= 2 and alreadystarted == true then
game.Workspace.SCRIPTNAME.Disabled = true
-- You can do this multiple times..
end
end)
Report Abuse
Dushax is not online. Dushax
Joined: 28 Apr 2010
Total Posts: 12892
31 May 2014 04:49 PM
Is it possible to put this under the 'if game.Players.NumberPlayers <= 2 and alreadystarted == true then'?

script.GuiText.Value = "You need "..game.Players.NumPlayers.." player to start the game! Invite someone such as a friend!"
wait()
Report Abuse
rodytenhoopen is not online. rodytenhoopen
Joined: 12 Nov 2010
Total Posts: 59
31 May 2014 05:30 PM
Yes it is, aslong its above the ends it's included in the functions.
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