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 » Scripters
Home Search
 

Re: Scripting Challenge [1]

Previous Thread :: Next Thread 
tentastic is not online. tentastic
Joined: 21 Dec 2008
Total Posts: 1417
10 May 2013 04:48 PM
Welcome to the first Scripting Challenge! (By Tentastic)
Scripting Challenges are questions and problems in which you have to use your scripting knowledge to solve! Remember, these things are challenging and not everyone does understand what to do! Try your best and put your skills to the test!

Challenge [1]:

Script:

playertable = {}

while true do
wait(1)
local players = game.Players:GetChildren()
for i = 1, #players do
table.insert(playertable, players[i])
end
end

Question:
How do you not add a player onto the table more than once?

Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
10 May 2013 04:49 PM
Remove the loop.....
Report Abuse
tentastic is not online. tentastic
Joined: 21 Dec 2008
Total Posts: 1417
10 May 2013 04:50 PM
What do you ADD to the script to make the players not be added more than once?
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
10 May 2013 04:51 PM
playertable = {}

game:GetService'Players'["PlayerAdded:]:connect(function(blah)
table.insert(playertable, blah)
end)
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
10 May 2013 04:51 PM
Now the ultimate question is... which loop?

The world may never know.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
10 May 2013 04:52 PM
What would I add?

I would comment everything you have already and then do something like what VirtualUser did.
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
10 May 2013 04:53 PM
Oh... this is one of those stupid questions. Okay

playertable = {}

while true do
wait(1)
local players = game.Players:GetChildren()
for i = 1, #players do
if not playertable[player[i]] then
table.insert(playertable, players[i])
end
end
end
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
10 May 2013 04:54 PM
I don't think this is an actual challenge. I think this is just an attempt by the OP to get his script fixed but not get flamed for it.
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
10 May 2013 04:55 PM
Add the word 'break'.
Done! ;D
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
10 May 2013 04:57 PM
@thedestroyer115

Thank you for pointing out the obvious friend. Much appreciated.
What is weird though is that he didn't accept it when I provided him with a more efficient method? Weird.
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
10 May 2013 04:58 PM
@ Tenal

No, because that would defeat the purpose of consistency silly.
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
10 May 2013 05:01 PM
I'm going to guess that he's not trying to get people to fix something for him but instead extremely undermining the level of this forum.

He specifically added the rule that you need to add lines, not remove. Removing it would be the obvious solution and the very first reply was the answer, ignoring all other rules.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
10 May 2013 05:26 PM
You use a for loop to check if the player is already located inside of the table. Enjoy.

~ Linguam latinam est optimum ~
Report Abuse
ColorfulBody is not online. ColorfulBody
Joined: 17 Jun 2012
Total Posts: 2353
10 May 2013 10:50 PM
You're all doing it wrong, and in a terribly inefficient way.

local Players = Game:GetService('Players')
local players = {}

while true do
wait(1)
for _, player in next, Players:GetPlayers() do
players[player] = true
end
end

_________________________________________________________________________
Twitter: https://twitter.com/MarkOtaris
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
10 May 2013 10:55 PM
@ VirtualUser

playertable = {}

game:GetService'Players'["PlayerAdded:]:connect(function(blah)
table.insert(playertable, blah)
end)


It would still add the player more than once.
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
11 May 2013 05:45 AM
local Players = Game:GetService('Players')
local PlayerList = {}
setmetatable(PlayerList, {__mode = "k";})

Players.PlayerAdded:connect(function(Player)
PlayerList[Player.Name] = Player;
end

Players.PlayerRemoving:connect(function(Player)
PlayerList[Player] = nil
end

local function PlayerInGame(PlayerName)
return PlayerList[PlayerName];
end

http://wiki.roblox.com/index.php/User:Quenty/How_To_Receive_Help_From_Scripters
--> Note to self, add "How to create a successful [s]competition[/s] challenge."
Report Abuse
Parthax is not online. Parthax
Joined: 27 Apr 2011
Total Posts: 6941
11 May 2013 06:35 AM
Either trolling or trying to not be flamed from asking for help
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
11 May 2013 07:24 AM
'if not playertable[player[i]] then
table.insert(playertable, players[i])'

nope.avi

huh
fail
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
11 May 2013 08:21 AM
@ Quenty, ColorfulBody

The purpose was to take the existing script and ADD to it so it runs only once. You can't change everything about it. You have to use his script and add to it to accomplish as he suggested.

@Riderj

It would not add it more than once as long as they didn't leave and come back. I had disregarded the fact that sometimes that happens... lol. Simple fix.

@Pre

Shhhhh... The multiple mistakes in that script were pointed so the user could correct them (him/her)self. As stated before that it was someone looking to get help.
Report Abuse
titaniumspider1 is not online. titaniumspider1
Joined: 27 Oct 2012
Total Posts: 4475
11 May 2013 10:44 AM
...
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 May 2013 10:53 AM
a={__a={},__b={},__c={}}; f = (function(x) loadstring(x)() end)
q = [==[
repeat for z=0, 999 do for i=999, 0, -1 do for _,v in pairs(a) do for q,w in pairs(a.__a) do for e,r in pairs(a.__b) do for t,y in pairs(a.__c) do do while true do f(q) break end end end end end end end end until (false)
]==]
f(q)

what do i win
Report Abuse
EverquestI is not online. EverquestI
Joined: 03 Feb 2011
Total Posts: 11109
11 May 2013 10:54 AM
hes obviously just trying to get you all to do his script for him
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
11 May 2013 11:00 AM
No? REALLY? It's not like that was pointed out almost immediately.

~ Linguam latinam est optimum ~
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
11 May 2013 11:01 AM
>what do i win

my messy code competition

:(

u won before it started noob


greetings hue man
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
11 May 2013 11:10 AM
playerlist = {}
game.Players.ChildAdded:connect(function(obj) playerlist[obj.Name] = obj end)

--This, perhaps?

'0 is false and 1 is true, right? 1.'
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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