|
| 29 Jan 2015 05:48 PM |
Ok, So this script is not working:
results()
function pick(num) local results = {} local stock = game.Players:GetChildren() if num<=#stock then for i=1, num do local picked = stock[math.random(1,#stock)] local del if stock[1] then for _,v in pairs(stock) do if picked == v then del = true break end end end if not del then table.insert(results,picked) end return results end else return false end end
function results() local results = pick(3) if results then game.Workspace.MainScript.Good.Value = results[1] game.Workspace.MainScript.Bad.Value = results[2] game.Workspace.MainScript.Accomplice.Value = results[3] end end
This is not the full script, But has the parts that are broken, It says String Error
on these lines:
game.Workspace.MainScript.Good.Value = results[1] and results()
What the script does is it picks 3 random players, making sure they are not the same player then puts all 3 names in a value. Well, its suppose to do that anyway. Thanks |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 05:52 PM |
Just through a brief skim of your script,
This line:
game.Workspace.MainScript.Good.Value = results[1]
should be
game.Workspace.MainScript.Good.Value = results[1].Name
Assuming 'Good' is a StringValue; The results table stores the userdata of the Player, not the actual string.
Also, use :GetPlayers() when looping through players.
I also don't see how returning false will help, because results() will still end up being called and if its looking through false[1]; That would send ROBLOX through the roof |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:14 PM |
On the line, when you add .Name it says this:
13:13:48.005 - Workspace.MainScript:53: attempt to index field '?' (a nil value) |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:22 PM |
function getRandom() return game.Players:GetPlayers()[math.random(game.Players.NumPlayers)] end
function choose3Rand() results = {} plr1,plr2,plr3 = getRandom(),getRandom(),getRandom() repeat plr2 = getRandom() until (plr2 ~= plr1 && plr2 ~= plr3) repeat plr3 = getRandom() until plr3 ~= plr1 table.insert(results,plr1) table.insert(results,plr2) table.insert(results,plr3) return results end
|
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:24 PM |
| Im confused now... Is this replacing the whole script? How do I use it? How can I use this to place the picked names in the 3 StringValues? |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:53 PM |
On this line:
repeat plr2 = getRandom() until (plr2 ~= plr1 && plr2 ~= plr3)
'&' underlines in red and says "Expected ')' (to close '( at column 33), got '&'
Line 31-33 says:
function getRandom() return game.Players:GetPlayers()[math.random(game.Players.NumPlayers)] end |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:55 PM |
I'm sorry
Change
repeat plr2 = getRandom() until (plr2 ~= plr1 && plr2 ~= plr3)
to
repeat plr2 = getRandom() until (plr2 ~= plr1 and plr2 ~= plr3) |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 07:39 PM |
| Thanks! This problem is finally fixed :P (This has literally been a development bug for like a week or so) |
|
|
| Report Abuse |
|
|