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: Trouble with tables

Previous Thread :: Next Thread 
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
16 May 2014 02:24 PM
Hi All
Does anyone know why this isn't working? It kinda half works because If two players have touched it and it is 0 time, then it displays ONE of the players, but not both. Any help would be appreciated. Thanks! :)

Winners = {}
script.Parent.Touched:connect(function(hit)
if hit.Parent.Name ~= Winners then
table.insert(Winners, hit.Parent.Name)
print("Player Added to table")
if game.Workspace.Time.Value == 10 then do
wait (10)
m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "The Winners are: "..unpack(Winners)
end
end
end
end)
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
16 May 2014 02:53 PM
Bump!
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 May 2014 02:54 PM
then do

remove the do..
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
16 May 2014 02:56 PM
Still doesn't work :(
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 May 2014 02:58 PM
I told you to do that because you dont need it there
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
16 May 2014 02:59 PM
I took it out and it still doesn't work
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
16 May 2014 03:22 PM
Take out the "do" and take out an "end"
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 03:26 AM
Done that and it still doesn't work :(
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 01:49 PM
Bump!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 01:51 PM
Winners = {}
script.Parent.Touched:connect(function(hit)
if not Winners[hit.Parent.Name] then
Winners[hit.Parent.Name] = true;
print("Player Added to table")
if game.Workspace.Time.Value == 10 then --although do won't cause an error here, it's useless
wait(10)
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "The Winners are: ".. table.concat(Winners, ", ");
end
end
end)
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 01:58 PM
Thanks!
But it didn't work.... :(
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:00 PM
Winners = {}

script.Parent.Touched:connect(function(hit)
if not Winners[hit.Parent.Name] then
Winners[hit.Parent.Name] = true;
print("Player Added to table")
end
if game.Workspace.Time.Value == 10 then
wait(10)
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "The Winners are: ".. table.concat(Winners, ", ");
Winners = {}; --reset it
end
end)
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:03 PM
That didn't work either :(
Is it maybe breaking because if the Time.Value isn't 10, then it doesn't do it? Basically, even if the time isn't 10, I still want it to remember the players that touched the brick and then when it is 10, say the players names!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:04 PM
Touch the part then make it 10.
It remembers already.
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:05 PM
But I don't want to display the names as soon as the player(s) touched it - only when the time reaches 10?!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:06 PM
It will do that.
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:08 PM
It doesn't work then :(
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:09 PM
In your script, you are making it only work when someone touches the part at 10 seconds. If you want it to automatically do it, just do:

Winners = {}

script.Parent.Touched:connect(function(hit)
Winners[hit.Parent.Name] = true;
print("Player added to table.")
end);

workspace.Time.Changed:connect(function(newValue)
if newValue == 10 then
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "The Winners are: ".. table.concat(Winners, ", ");
Winners = {}; --reset it
end
end);
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:11 PM
I don't mean that! :D I want the brick to remember any players that touch it while the Time is above/below/not == 10, and then, when the Time.Value is 10, display the players names :)
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:11 PM
If that makes sense :D
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:16 PM
You just said exactly what I did lol
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:18 PM
Sorry! XD I tested it and It displays this when the time is 10:
"The Winners Are:


Where are the winners......? :D
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:19 PM
Change 'Winners[hit.Parent.Name] = true;' to
'Winners[#Winners + 1] = hit.Parent.Name'
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 May 2014 02:21 PM
Won't that break if the player is already in the table or add them again?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 May 2014 02:22 PM
Oh, yeah I totally forgot to check xD.

script.Parent.Touched:connect(function(hit)
for key, value in next, Winners do
if value == hit.Parent.Name then
return
end
end
Winners[#Winners + 1] = true;
end);
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