Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
|
| 27 Aug 2015 11:42 PM |
itemname = Workspace.ORDER1VALUE.Value
if script.Parent.Parent.Parent.Parent.Backpack[itemname].Archivable == true then
I know where the issue is, and it's really simple but for some reason I can't solve it.
It's clearly in the "Backpack[itemname]." part, it's so easy and yet I'm having trouble with it. I know the answer is simple, so don't be all like "OMG THIS IS SO EASY HOW CAN'T YOU FIGURE THIS OUT". qq |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 11:44 PM |
if you're just checking if it exists then do this
itemname = Workspace.ORDER1VALUE.Value
if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild(itemname) then |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 11:55 PM |
| script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild[itemname].Archivable == true then |
|
|
| Report Abuse |
|
|
|
| 28 Aug 2015 12:04 AM |
| I don't think he's using the archivable setting the way it's intended. If you're using the archivable property to check if an object exists, your script will end badly with failed to find nil value |
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
|
| 28 Aug 2015 01:39 AM |
^ Exactly, however the edit you gave me did reduce the NIL error, but it didn't quite work.
Here's the full script if it helps:
playerbackpack = script.Parent.Parent.Parent.Parent.Backpack itemname = Workspace.ORDER1VALUE.Value item = playerbackpack:FindFirstChild(itemname) function clicked() print(11) if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild(itemname) then Workspace.ya1.Position = Vector3.new(21.41, -0.5, 23.425) Workspace.NPC1.Humanoid.Health = 0 script.Parent:Destroy() print(22) end end script.Parent.MouseButton1Down:connect(clicked)
|
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
|
| 28 Aug 2015 08:36 AM |
slight edit
itemname = Workspace.ORDER1VALUE.Value
if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild(itemname) ~= nil then
|
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
|
| 28 Aug 2015 02:19 PM |
| Same thing, no errors but it doesn't work. The output just repeats 11 every time I push the button. |
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
|
| 28 Aug 2015 03:29 PM |
| gagagagagagagag ollalalala |
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Grozztok
|
  |
| Joined: 06 Oct 2012 |
| Total Posts: 87 |
|
|
| 28 Aug 2015 09:03 PM |
| uh, instead of "itemname = Workspace.ORDER1VALUE.Value" try "itemname = Workspace.ORDER1VALUE"? otherwise you're setting the variable to the value right |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 28 Aug 2015 09:04 PM |
if it just prints 11 tha means
playerbackpack = script.Parent.Parent.Parent.Parent.Backpack itemname = Workspace.ORDER1VALUE.Value item = playerbackpack:FindFirstChild(itemname) function clicked() print(11) if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild(itemname) then Workspace.ya1.Position = Vector3.new(21.41, -0.5, 23.425) Workspace.NPC1.Humanoid.Health = 0 script.Parent:Destroy() print(22) end end script.Parent.MouseButton1Down:connect(clicked)
script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild(itemname) is false are you sure its not false?
|
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
|
| 28 Aug 2015 09:55 PM |
| o, yeah I'm sure it's not false |
|
|
| Report Abuse |
|
|
Lucargia
|
  |
| Joined: 25 Jan 2013 |
| Total Posts: 371 |
|
| |
|
|
| 28 Aug 2015 11:21 PM |
You don't just print values like that. Consider using
itemname = Workspace.ORDER1VALUE
|
|
|
| Report Abuse |
|
|