local function partTouched(onTouch)
local tool = game.Players:FindFirstChild("Tool")
if tool.Name == "Sword" then
tool:Destroy()
end
end
script.Parent.Touched:Connect(partTouched)
I made this script to remove your sword when you touch this part It doesn't work for some reason and here is the output error:
11:30:44.415 - Workspace.Part.Script:3: attempt to index nil with 'Name'

9 comments
are you sure there is a tool in players?
yes i put a tool in starterpack which should mean theres one in the backpack of the player
then you do local tool = game.Palyers.Backpack:FindFirstChild("Tool")
players*
i dont think you understand where the backpack is
script.Parent.Touched:connect(function(p) if p.Parent.Name == "Key" then p.Parent:Destroy() end end)
bruh backpack is in the localplayer that is in players
That can do it if they are holding the tool.
yes but you cant say game.Players.backpack lol