|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 07 May 2015 05:57 PM |
| I meant a reference to the value, but that is besides the point. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|