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

How do I remove a tool from one's backpack after use?

Asked by
vocful 6
5 years ago
Edited 5 years ago

POC: How do I remove a tool from one's backpack after use?

IDEA: For instance, if one finds a key and touches a door, the door will open (transparency = 1, can collide = false), but the key is still in the user's inventory. Also, how do I delete the door rather than typing more lines of code?

NOTES: I was told from a friend that I should use tool:Delete(), but I do not know how to use it because my script does work completely. I've also seen Part:Delete(), but there's always an error that I do not know how to fix.

1script.Parent.Touched:connect(function(p)
2if p.Parent.Name == "CopperKey" then
3script.Parent.Transparency = 1
4script.Parent.CanCollide = false
5end
6end)

OVERALL: -How do I write the script when a certain tool touches a brick, the tool deletes itself from the user's inventory? -How do I delete the part?

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Your issue is the fact that Delete is not a method of Instance, I believe you’re trying to call Destroy.

1local Part = script.Parent
2 
3Part.Touched:Connect(function(Hit)
4    if (Hit:FindFirstAncestor("CopperKey")) then
5        Part:Destroy()
6    end
7end)
0
Theres an error. vocful 6 — 5y
0
Apologies, I fixed the Syntax error Ziffixture 6913 — 5y
Ad

Answer this question