Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 13 Jul 2016 05:57 PM |
function Died() script.Parent.SwordName.Value:Destroy() end script.Parent.Human.Died:connect(Died)
The script is for example, scriptinghelpers seems to not help so i ask here... The value that holds the item name is in a script named SwordCarrier and that script is in a model parent NPC , also the sword is in NPC too. So what i want when the npc dies script gets what name is written in the VALUE and if that value's name item named like in value EXISTS then delete it when the NPC dies. So how i make it exactly what i wrote here ? |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2016 06:23 PM |
@OP Have you tried using an ObjectValue? (Note: Idk if the following code will work)
local objval = Instance.new('ObjectValue', assetparent) -- Creates a new ObjectValue, and sets it's parent to the assetparent objval.Value = assetchild -- The Value has been set to the assetchild; think of objval.Value as a variable, like ObjValAsset = assetchild
objval.Value:Destroy() -- Destroy it through the value
I'm not 100% if this will work though. ;-;
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 13 Jul 2016 06:27 PM |
| I dont need it to instance i need an exact way of doing what i wrote in the script vbecause other acript clones the sword into the npc through the value name and now i wantit to destroy checking the value's name the sword but not the value |
|
|
| Report Abuse |
|
|
D4rkly
|
  |
| Joined: 11 Oct 2009 |
| Total Posts: 1198 |
|
|
| 13 Jul 2016 06:28 PM |
So... you want the object value to remove the said sword model when the npc dies?
Hard to understand you when you throw together words in a sloppy manner..
~D4rkly |
|
|
| Report Abuse |
|
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 13 Jul 2016 06:31 PM |
Look, read closely Theres a name in the value that gas the sword's name when character sies that script checks the value's text if that npc dies with the sword he has exact name in the value DELETE IT. There ya go |
|
|
| Report Abuse |
|
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 13 Jul 2016 06:33 PM |
| Sorry if i write bad, whenever i explain i always try to explain so ppl can answer easily ;D also im Lithuanian |
|
|
| Report Abuse |
|
|
D4rkly
|
  |
| Joined: 11 Oct 2009 |
| Total Posts: 1198 |
|
|
| 13 Jul 2016 06:35 PM |
val = Instance.new("ObjectValue") val.Value = script.Parent["SwordBrickNameHere"]
function Died() val.Value:remove() end script.Parent["HUMANOID_NAME_HERE"].Died:connect(Died)
~D4rkly |
|
|
| Report Abuse |
|
|
D4rkly
|
  |
| Joined: 11 Oct 2009 |
| Total Posts: 1198 |
|
|
| 13 Jul 2016 06:36 PM |
oh, and don't forget to parent the val to the model.
~D4rkly |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2016 06:42 PM |
@D4rkly Eyyyyy, you copied me, and didn't credit me. ;-; Meanie.
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
D4rkly
|
  |
| Joined: 11 Oct 2009 |
| Total Posts: 1198 |
|
|
| 13 Jul 2016 06:49 PM |
Those comments after "Your" code sway my vote that indeed, you sir, are the copier.
~D4rkly |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2016 06:57 PM |
@D4rkly My reply was there before yours, so you sir, are the copier. ;)
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
Bulvyte
|
  |
| Joined: 21 May 2014 |
| Total Posts: 716 |
|
|
| 14 Jul 2016 02:10 AM |
| Is there another way without instancing it... |
|
|
| Report Abuse |
|
|
Repsej112
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 205 |
|
|
| 14 Jul 2016 03:34 AM |
function Died() local valExists = script.Parent.SwordName:FindFirstChild("Value") if valExists then valExists:Destroy() end script.Parent.Human.Died:connect(Died) |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 04:05 PM |
@OP There's a way; however, for the code I'm about to use, you'll have to set up 'SwordName' to represent the value; you HAVE to use a string value, and have the Value contain the assets' name for the code below.
local SwordName = script.Parent.SwordName
if script.Parent:FindFirstChild(SwordName.Value) then script.Parent[SwordName.Value] end
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|