Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to remove something that is in named value ?

Asked by
Bulvyte 388 Moderation Voter
7 years ago
Edited 7 years ago

Example:

function Died()
    script.Parent.SwordName.Value:Destroy() -- a sword gets cloned into npc from value, value has the sword's name so how do u destroy the sword checking the value with the script ????? im so confuuused

end

script.Parent.Human.Died:connect(Died)

My other script clones the sword into the npc from a value, but i want this when he dies the script checks the value's name and according to that value's name the script should remove the sword from the value's name. HOW I DO DAT ???

0
Try :FindFirstChild("name"). GoldenPhysics 474 — 7y

2 answers

Log in to vote
0
Answered by
shayner32 478 Trusted Moderation Voter
7 years ago

Try this code out:

function Died()
    script.Parent.SwordName["Value"]:Destroy() -- a sword gets cloned into npc from value, value has the sword's name so how do u destroy the sword checking the value with the script ????? im so confuuused

end

script.Parent.Human.Died:connect(Died)

I haven't tested it, but it should work just fine.

0
I dont think itll work the value is in swordcarrier script Bulvyte 388 — 7y
Ad
Log in to vote
0
Answered by
thePyxi 179
7 years ago

The script down below will check the sword's value. If it is that value, then it will destroy the sword. If the value is not named correctly, it will print "Not named correctly".

function Died()
    if script.Parent.SwordName.Value == "Value Name" then
        script.Parent.SwordName:Destroy()
    else
        print("Not named correctly")
    end
end

script.Parent.Human.Died:connect(Died)

0
"Value Name" how dors that work? Bulvyte 388 — 7y
0
"Value Name" how dors that work? Bulvyte 388 — 7y
0
You put in whatever you set the Value of SwordName is. thePyxi 179 — 7y
0
Can you reedit the lines parents ? The value is in the SwordCarrier script and that script is in the npc, sword is also in the npc i cant reedit them cuz idk how it should be also not at PC :/ Bulvyte 388 — 7y
View all comments (3 more)
0
No... I dont think this will work Bulvyte 388 — 7y
0
Are you trying to compare the actual value of the object or the name of the object? GoldenPhysics 474 — 7y
0
I don't know how to explain to you guys, but ill try again. When the char dies, script check's the value's name of the sword in the value, if it exist's then removes sword in the NPC what's named in the VALUE... Bulvyte 388 — 7y

Answer this question