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
 

Script not working

Previous Thread :: Next Thread 
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
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
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
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
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
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
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
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
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
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
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
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
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
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
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
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
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