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 » Scripting Helpers
Home Search
 

Re: Why won't this work?

Previous Thread :: Next Thread 
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 06:38 PM
This is supposed to set the last person alive as the "Winners" value. (The 'Winner' is an ObjectValue). But nothing happens.

People = {}

for i,v in pairs(game.Players:GetChildren()) do
table.insert(People,v)
while wait(1) do
v.Character.Humanoid.Died:connect(function()
table.remove(People,v)
end)
end
end

wait(1)

while wait(.5) do
if #People < 2 then
if People[1] then
script.Parent.Winner.Value = People[1]
end
end
end
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 06:48 PM
Anyone? Please help?
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
20 Apr 2013 06:49 PM
People = {}

for i,v in pairs(game.Players:GetChildren()) do
table.insert(People,v)
while wait(1) do
v.Character.Humanoid.Died:connect(function()
table.remove(People,v)
end)
end
end

wait(1)

while wait(.5) do
if #People == 1 then
script.Parent.Winner.Value = #People
end
end

try that
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 06:52 PM
@Master

But that would set the value of 'Winner' to the NUMBER of People. Not the actual person... :c
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
20 Apr 2013 06:53 PM
People = {}

for i,v in pairs(game.Players:GetChildren()) do
table.insert(People,v)
while wait(1) do
v.Character.Humanoid.Died:connect(function()
table.remove(People,v)
end)
end
end

wait(1)

while wait(.5) do
if #People == 1 then
script.Parent.Winner.Value = People[1].Name
end
end
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 07:03 PM
I need the actual person, not the name. I'll just remove the '.Name' part. Lol
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
20 Apr 2013 07:04 PM
You can't make a person a value...
Report Abuse
MassiveGman is not online. MassiveGman
Joined: 23 Jan 2011
Total Posts: 2019
20 Apr 2013 07:05 PM

Both the key and value can be any Lua value (numbers, strings, Parts etc., and even other tables)

|MassiveGman| Scripter & part time Professional Whistler
Report Abuse
MassiveGman is not online. MassiveGman
Joined: 23 Jan 2011
Total Posts: 2019
20 Apr 2013 07:06 PM
Oh, you literally mean a value.

You could use the Name.

Oh wait..

Erm.
Nevermind.



|MassiveGman| Scripter & part time Professional Whistler
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
20 Apr 2013 07:50 PM
He said it was an ObjectValue. It's just like the 'creator' value that is the foundation of the leaderboard.
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 08:05 PM
Yes, you can have a player as a value. That's what the "ObjectValue" is for...

I've done it before...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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