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: Help with this Player Script

Previous Thread :: Next Thread 
spearmint123 is not online. spearmint123
Joined: 11 Feb 2010
Total Posts: 139
07 May 2015 05:32 PM
Here:
local players = game.Players:GetChildren()
local num = game.Players.NumPlayers

wait(1)
local p = Instance.new("Message")

function PlayRev()

p.Parent = game.Workspace
local a = tostring("There are " ..num .." players in the game")
p.Text = (a)
wait(1)

for i, v in pairs(players) do
print(i, v)
p.Text = v.Name
wait(1)
end

wait(1)
p:Destroy()
end

game.Players.PlayerAdded:connect(PlayRev)
game.Players.PlayerRemoving:connect(PlayRev)



This does not produce an error, I just spawn in and nothing happens; also, I can't seem to be able to write the call function line with just "Players" and not "game.Players" without getting an error (probably unrelated).
Report Abuse
spearmint123 is not online. spearmint123
Joined: 11 Feb 2010
Total Posts: 139
07 May 2015 05:39 PM
*Sadbump
Report Abuse
ThaneTheCreator is not online. ThaneTheCreator
Joined: 08 Apr 2009
Total Posts: 2182
07 May 2015 05:45 PM
It's because you classify Num before everything, and it doesn't update.

You need this inside the PlayRev() function:

local players = game.Players:GetChildren()
local num = game.Players.NumPlayers

~who's awesome? you're awesome!
Report Abuse
spearmint123 is not online. spearmint123
Joined: 11 Feb 2010
Total Posts: 139
07 May 2015 05:49 PM
That didn't work ty for the guess though. once a variable is assigned to a value, anytime that value changes, shouldn't the variable value since it's only a reference?

Back to square one with all my stupid mistakes.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
07 May 2015 05:51 PM
^

It is not a reference to that

Anytime you set a variable to a property, it won't reference the property, it'll contain the value of it
Report Abuse
spearmint123 is not online. spearmint123
Joined: 11 Feb 2010
Total Posts: 139
07 May 2015 05:57 PM
I meant a reference to the value, but that is besides the point.
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
07 May 2015 06:01 PM
try this

msg = Instance.new("Message",game.Workspace)

game.Players.PlayerAdded:connect(function(p)
msg.Text = "There are "..game.Players.NumPlayers.." in the server!"
wait(1)
for i,v in pairs(game.Players:getChildren()) do
msg.Text = v.Name
wait(1)
end
wait(1)
msg:Destroy()
end)


and do the same for when they leave.
Report Abuse
spearmint123 is not online. spearmint123
Joined: 11 Feb 2010
Total Posts: 139
07 May 2015 06:07 PM
^^Very helpful, I found it weird to put your function definition in the call line though, though it seems to be common syntax.
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