|
| 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 |
|
|
| |
|
| |
|
| |
|
|
| 16 May 2014 02:58 PM |
| I told you to do that because you dont need it there |
|
|
| Report Abuse |
|
|
|
| 16 May 2014 02:59 PM |
| I took it out and it still doesn't work |
|
|
| Report Abuse |
|
|
|
| 16 May 2014 03:22 PM |
| Take out the "do" and take out an "end" |
|
|
| Report Abuse |
|
|
|
| 17 May 2014 03:26 AM |
| Done that and it still doesn't work :( |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 17 May 2014 01:58 PM |
Thanks! But it didn't work.... :( |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
| |
|
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 |
|
|
|
| 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 |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 May 2014 02:16 PM |
| You just said exactly what I did lol |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|