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

A script that removes a tool on touch of a part

I tried doing

script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
game.Players[hit].Backpack.Key:Destroy()
end
end)

but it didn't work and I used the same name "Key for the tool" any help will be truly appreciated

Thanks,

Exsius,

2 comments

1

Your problem would have to be the name of the "Key" as the rest of your script works. If the player can hold the "Key" then you may also want to check their character as that's where tools that are being held are.

0

Where do I check I can't find "characters"

1 answer

toolname = "Tool name"
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
	char = hit.Parent
	plr = game.Players:GetPlayerFromCharacter(char)
	if plr.Backpack:findFirstChild(toolname) then
		plr.Backpack[toolname]:Destroy()
	end
end
end)

-Thank me by accepting this answer/bumping up my reputation!

1 comment

0

That wouldn't work if they were holding the tool.

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