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: How..

Previous Thread :: Next Thread 
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 09:26 PM
local Snail1 = (Players[math.random(1, #Players)])
local Snail2 = (Players[math.random(1, #Players)])

How do i get The First Player, to not be chosen twice?
Report Abuse
Awsomisticguy537 is not online. Awsomisticguy537
Joined: 03 Dec 2010
Total Posts: 507
03 Jun 2013 09:47 PM
Maybe a bool value in each playet that is made false default, but turns true when chosen. If true then find a new player, if false then it works. Once all players are true, change them back to false.
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
03 Jun 2013 09:50 PM
There is probably a better way, but my love for values says that he is correct ^
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:00 PM
@ 2 Above
So how would i do this, do you have a defined script code?
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:03 PM
Im not seeing how that would work with what i have ..
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
03 Jun 2013 10:11 PM
game.Players.ChildAdded(function(plr)
efaswfd = Instance.new("BoolValue", plr)
efaswfd = "PlayerisChosen"
end
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
03 Jun 2013 10:11 PM
game.Players.ChildAdded(function(plr)
efaswfd = Instance.new("BoolValue", plr)
efaswfd.Name = "PlayerisChosen"
end

fix*
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Jun 2013 10:12 PM
players = game.Players:GetPlayers()
players.pop = table.remove

Snail1 = players:pop(math.randomI(#players))
Snail2 = players:pop(math.randomI(#players))
Report Abuse
Awsomisticguy537 is not online. Awsomisticguy537
Joined: 03 Dec 2010
Total Posts: 507
03 Jun 2013 10:13 PM
Im assuming that something happens when a player is selected. Make one of those things the value change.

if game.Players.(selectedPlayer).(bin the value is in).TheValue.Value == false then
make value true
begin effects

else

repeat/return or whatever.

Then theres some method out there like GetAllChildrenOf or something like that, which can find the boolean of each player. Once they all read true, have it automatically make them all false.

Obviously thats a very simplified version of the script you're asking for.
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:13 PM
smurf what does that do?
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Jun 2013 10:15 PM
it just removes the selected player from the table so it removes the possibility of a player being picked twice. I wrote it a little funny so it might look confusing
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:16 PM
Is GetPlayers() a function?
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:17 PM
Here is what i have:
Tell me Will this work (And i know the MoveTo wont im still finishing the script)
function Activate()
if game.Players.NumPlayers <= 2 then
game.Workspace.GameNews.Value = "There is not enough players. invite your friends!"
wait(2)
Activate()
end
game.Workspace.GameNews.Value = "Hello welcome to the game, the game will start soon"
wait(10)
game.Workspace.GameNews.Value = "Loading Map"
wait(2)
game.Workspace.GameNews.Value = "Selecting Map..."
wait(1.5)
local gamemaps = game.Lighting.Maps:GetChildren()
local chosen = (gamemaps[math.random(1, #gamemaps)]):clone()
game.Workspace.GameNews.Value = "The chosen map is: "..chosen.Name.." made by "..chosen.Creator.Value
chosen:MoveTo(Vector3.new(0,0,0))
chosen.Name = "GameMap"
chosen.Parent = game.Workspace
chosen.Creator:remove()
wait(2)
game.Workspace.GameNews.Value = "Selecting two players.."
players = game.Players:GetPlayers()
players.pop = table.remove
Snail1 = players:pop(math.randomI(#players))
Snail2 = players:pop(math.randomI(#players))
wait(2)
game.Workspace.GameNews.Value = "Loading Game"
Snail1:MoveTo(game.Workspace.GameMap.Spawn1)
Snail2:MoveTo(game.Workspace.GameMap.Spawn2)
while wait(3) do
if game.Workspace.Finish.Value == false then
game.Workspace.GameNews.Value = "A game is currently running"
elseif game.Workspace.Finish.Value == true then
Continue()
end
end

function Continue()
Player = game.Players:findFirstChild(""..game.Workspace.Winner.Value"")
game.Workspace.GameNews.Value = ""..game.Workspace.Winner.Value" has crossed the finish line!"
wait(3)
game.Workspace.GameNews.Value = "And "..game.Workspace.Winner.Value.." has won the cup!"
wait(2)
Player.leaderstats.RacesWon.Value = Player.leaderstats.RacesWon.Value + 1
end
wait(7)
Activate()
end
Activate()
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
03 Jun 2013 10:21 PM
I have to go to sleep, ill check in tommorow morning, bye guys :) Thanks for the help please tell me if the post will work , or if it doesnt the fix to it.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Jun 2013 10:31 PM
im pretty sure it will work(at least the code I wrote)
and yes getplayers is a function(method). in case you store extra objects in players, which you shouldn't, getplayers only collects players. getchildren works just fine though
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