tidus019
|
  |
| Joined: 12 Nov 2008 |
| Total Posts: 132 |
|
|
| 19 May 2013 07:46 AM |
Hello, I have a (relatively) simple question: How do you use an ObjectValue, and in which scenarios would it be good to use one?
The wiki didn't realy explain it to me. "An ObjectValue is a very simple value; it holds an object reference as it's value."
Thanks |
|
|
| Report Abuse |
|
|
|
| 19 May 2013 07:52 AM |
| i wouldn't use it. its just a more complicated way that's just simply unnecessary. |
|
|
| Report Abuse |
|
|
|
| 19 May 2013 08:18 AM |
A good example of the use of object values is the tagging KOs by weapons. When a player dies, roblox checks for an ObjectValue called "creator" inside that players humanoid. If that object value exists, roblox awards the player that object value references a KO.
For example the value of the creator ObjectValue could be : game.Players.TheGamer101 |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
|
| 19 May 2013 08:26 AM |
It is pretty useful, like TheGamer101 said, to store player names. If you want a tycoon block only collectible by the owner you would do something like: function OnTouch(Toucher) if Toucher.Parent == ObjectValue.Value then harvest() else print("You do not own this block!") end end
I didn't test that so the syntax is probably off, but you get the point. |
|
|
| Report Abuse |
|
|
tidus019
|
  |
| Joined: 12 Nov 2008 |
| Total Posts: 132 |
|
|
| 20 May 2013 04:24 AM |
| Ah! That's useful indeed. This way you can make things only useable by one player in a very neat way. Thanks! |
|
|
| Report Abuse |
|
|