|
| 29 May 2015 09:22 PM |
- Tag is not a valid member of Player
What??
function checkplayers() for _,v in pairs(game.Players:GetPlayers()) do if v.Tag then playersdead = false else playersdead = true end end end
If the tag doesn't exist then why doesn't it just keep the value at false instead of printing an error? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 29 May 2015 09:24 PM |
| if v:FindFirstChild("Tag") then |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 29 May 2015 09:25 PM |
You are trying to index Tag and when it is not there it errors.
http://wiki.roblox.com/index.php?title=FindFirstChild
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:27 PM |
| Thank you. Is FindFirstChild used for that? I thought it was just a fancy way of saying v.Tag |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:35 PM |
No, FindFirstChild IS used for that EXACT purpose. You don't even need FindFirstChild to find things with spaces in the name; you can do Parent["Child With Spaces"]
Roblox was really dumb to not add support for returning nil. Instances and Vector3s and stuff like that are Userdata. Userdata need to have functions set up for them defined by who makes it. Roblox just didn't add support for returning nil, which was WAY stupid. |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:38 PM |
> Roblox was really dumb to not add support for returning nil.
What exactly do you mean by "add support for returning nil"? |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 29 May 2015 09:39 PM |
>What exactly do you mean by "add support for returning nil"?
I believe he's referring to the way the script errors when you reference a non-existent object, instead of simply returning as nil. |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:41 PM |
Yes. Because now you can't do "if workspace.Something then", and it confuses a LOT of people. And "What exactly do you mean by 'Add support for returning nil'?" is somewhat obvious, as I explained what I meant in the post that I said it. Roblox didn't add support for it when they made the userdata. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 29 May 2015 09:48 PM |
| We should make a wrapper that fixes that! |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:52 PM |
| The way it was worded made it sound at first like "support for how to handle an already returned nil". Sorry about that. |
|
|
| Report Abuse |
|
|
|
| 29 May 2015 09:55 PM |
| It was and is intentional because in many cases it makes more sense for it to error rather than just return a nil value. |
|
|
| Report Abuse |
|
|