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
 

Re: Why isnt this printing anything?

Previous Thread :: Next Thread 
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 05:58 AM
if game.Workspace.Finished == true then
wait(10)
local scores = {}
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(scores, v:WaitForChild("IntValue"))
end
table.sort(scores, function(a, b) return a.Value > b.Value end)
print(scores[1].Parent.Name .. " came in first! Score: " .. tostring(scores[1].Value))
print(scores[2].Parent.Name .. " came in second! Score: " .. tostring(scores[2].Value))
print(scores[3].Parent.Name .. " came in third! Score: " .. tostring(scores[3].Value))
print(scores[4].Parent.Name .. " came last. Score: " .. tostring(scores[3].Value))

end

It should print the username and what position they came in.

But it isnt printing anything, even when the boolean is activated.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
17 May 2015 06:08 AM
You're only checking if it is true once. Use the .Changed event.

game.Workspace.Finished.Changed:connect(function()
if game.Workspace.Finished.Changed.Value = true then
wait(10)
local scores = {}
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(scores, v:WaitForChild("IntValue"))
end
table.sort(scores, function(a, b) return a.Value > b.Value end)
print(scores[1].Parent.Name .. " came in first! Score: " .. tostring(scores[1].Value))
print(scores[2].Parent.Name .. " came in second! Score: " .. tostring(scores[2].Value))
print(scores[3].Parent.Name .. " came in third! Score: " .. tostring(scores[3].Value))
print(scores[4].Parent.Name .. " came last. Score: " .. tostring(scores[3].Value))
end

end)
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 06:23 AM
Nothing came out...

Im at a loss here, I dont get why it's not printing anything when it should be.
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 06:33 AM
...
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
17 May 2015 06:38 AM
Wrote it wrong. >_>

game.Workspace.Finished.Changed:connect(function()
if game.Workspace.Finished.Value = true then
wait(10)
local scores = {}
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(scores, v:WaitForChild("IntValue"))
end
table.sort(scores, function(a, b) return a.Value > b.Value end)
print(scores[1].Parent.Name .. " came in first! Score: " .. tostring(scores[1].Value))
print(scores[2].Parent.Name .. " came in second! Score: " .. tostring(scores[2].Value))
print(scores[3].Parent.Name .. " came in third! Score: " .. tostring(scores[3].Value))
print(scores[4].Parent.Name .. " came last. Score: " .. tostring(scores[3].Value))
end

end)
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 07:01 AM
I think it may be an underlying problem.

This, for example, isnt working:

game.Workspace.Finished.Changed:connect(function()
if game.Workspace.Finished == true then
wait(6)
workspace.applause:Play()
end
end)

And considering your really good with scripting, i think it may be a problem with the variable itself, or something else...
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
17 May 2015 07:05 AM
Put a bunch of prints after everything and check where it stops.

Also, can I have the paths like:

-Workspace
--Finished (Boolean)



Report Abuse
spinywind is online. spinywind
Joined: 26 Jan 2012
Total Posts: 3580
17 May 2015 07:10 AM
do you want it to print as a message or on a score board or gui o something like that because when you say print(hfsdgsdgsdhfs) that only prints to output
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 07:14 AM
It stops here:

table.insert(scores, v:WaitForChild("IntValue"))
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 07:19 AM
I only want it to print to output.
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
17 May 2015 07:23 AM
v:WaitForChild("IntValue")

if it stop here it probably i waiting for an instance named IntValue inside of v right. :3
check if that value exists.
Report Abuse
AlgyLacey is not online. AlgyLacey
Joined: 14 Jun 2013
Total Posts: 3736
17 May 2015 07:26 AM
Found la problemo.

"game.Workspace.Finished.Value == true"

Finished is an object, and therefore will never equal true. :)


{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-}
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
17 May 2015 07:39 AM
.Value

...
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 07:46 AM
The IntValue stores how many points a user got

It is inside every single user

and it is located in game.Players.(user).value
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
17 May 2015 07:48 AM
Oh. Wait. I understood algy wrong. He's right. Replace the first line with:

while game.Workspace.Finished.Value == true do
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 07:50 AM
AHA! I FOUND THE ROOT PROBLEM

i managed to get the intvalue defined.

It was about to print the username and the position they came in.

But instead it spat out this:

Workspace.Scoring:15: attempt to index field '?' (a number value)
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 08:09 AM
guys...
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 08:38 AM
erm...
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
17 May 2015 08:42 AM
I'm not going to count lines. what line is line 15?
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 08:47 AM
Isn't it obvious?

Line 15 is where it starts to print the username and values:

print(scores[1].Parent.Name .. " came in first! Score: " .. tostring(scores[1].Value))
print(scores[2].Parent.Name .. " came in second! Score: " .. tostring(scores[2].Value))
print(scores[3].Parent.Name .. " came in third! Score: " .. tostring(scores[3].Value))
print(scores[4].Parent.Name .. " came last. Score: " .. tostring(scores[3].Value))
Report Abuse
GOLDC3PO is not online. GOLDC3PO
Joined: 31 May 2011
Total Posts: 509
17 May 2015 08:50 AM
game.Workspace.Changed:connect(function()
if game.Workspace.Finished.Changed.Value = true then
wait(10)
local scores = {}
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(scores, v:WaitForChild("IntValue"))
end
table.sort(scores, function(a, b) return a.Value > b.Value end)
print(scores[1].Parent.Name .. " came in first! Score: " .. tostring(scores[1].Value))
print(scores[2].Parent.Name .. " came in second! Score: " .. tostring(scores[2].Value))
print(scores[3].Parent.Name .. " came in third! Score: " .. tostring(scores[3].Value))
print(scores[4].Parent.Name .. " came last. Score: " .. tostring(scores[3].Value))
end

end)
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
17 May 2015 08:52 AM
add this before that line and give me the output

print(scores[1], type(scores[1]))
print(scores[1].ClassName, scores[1].Parent)
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 09:00 AM

3 number

Workspace.Scoring:16: attempt to index field '?' (a number value)
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 09:05 AM
It did print the number of points i got, so that's a good sign.
Report Abuse
jordanNin64 is not online. jordanNin64
Joined: 07 Jun 2013
Total Posts: 2457
17 May 2015 09:13 AM
bump.
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