Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to remove something that is in named value ?

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 ???

1 comment

0

Try :FindFirstChild("name").

2 answers

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.

1 comment

0

I dont think itll work the value is in swordcarrier script

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)

7 comments

0

"Value Name" how dors that work?

0

"Value Name" how dors that work?

0

You put in whatever you set the Value of SwordName is.

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 :/

0

No... I dont think this will work

0

Are you trying to compare the actual value of the object or the name of the object?

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...

This discussion is preserved as it was. New answers, comments, and votes are closed.