|
| 03 Jan 2015 04:33 PM |
Hi guys! I have a brick with a script in that remembers everyone that touches it and at the end it displays who touched it - that is working fine. But now I need it in a model and it doesn't work in a model - any ideas why? Here's the script: Another problem, is that there is more than one of these in the game - I kinda also need a way to run only THE one that is touched or something. Any help would be appreciated! Thanks
local Winners = {}; script.Parent.Touched:connect(function(hit)--when the brick is touched print ("Player touched!") for key, value in next, Winners do if value == hit.Parent.Name then return end end table.insert(Winners, hit.Parent.Name) end); game.Workspace.Time.Changed:connect(function(newValue) if newValue == 0 then --if the time is equal to 1 then hdd= game.Workspace.Announcer end if #Winners == 0 then hdd.Text = "Nobody Escaped." else hdd.Text = "The players that Escaped are: "..table.concat(Winners, ", "); --display the winners in a message wait(3) hdd.Text = "" for key, value in next, Winners do local c = game.Players[value].leaderstats.Coins c.Value = c.Value + 10; end end end);
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
Funse
|
  |
| Joined: 11 Jun 2012 |
| Total Posts: 7887 |
|
|
| 03 Jan 2015 04:55 PM |
script inside of the model
local Winners = {}; for i,v in pairs(script.Parent:GetChildren()) if v:IsA('Part') then v.Touched:connect(function(hit)--when the brick is touched print ("Player touched!") for key, value in next, Winners do if value == hit.Parent.Name then return end end table.insert(Winners, hit.Parent.Name) end); game.Workspace.Time.Changed:connect(function(newValue) if newValue == 0 then --if the time is equal to 1 then hdd= game.Workspace.Announcer end if #Winners == 0 then hdd.Text = "Nobody Escaped." else hdd.Text = "The players that Escaped are: "..table.concat(Winners, ", "); --display the winners in a message wait(3) hdd.Text = "" for key, value in next, Winners do local c = game.Players[value].leaderstats.Coins c.Value = c.Value + 10; end end end end end); |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2015 04:57 PM |
| Doesn't work :( When the time is set to 0 (or any other time) it says "Players that Escaped: Workspace" (Also, bear in mind i have more then one of those scripts in the game in a model) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 04 Jan 2015 02:43 PM |
| Is there another more efficient way of doing this or something? |
|
|
| Report Abuse |
|
|
| |
|
|
| 04 Jan 2015 02:53 PM |
| Basically, I just need an efficient way to collect the names of players that touched a brick in a round so I can display them on a Gui :( |
|
|
| Report Abuse |
|
|
| |
|
| |
|