function hit(part) if hit == nil then return end h = game.Players:GetPlayerFromCharacter(part.Parent) if h ~= nil then c = h.Backpack:GetChildren() for i=1,#c do c[i]:remove() end end end
script.Parent.Touched:connect(hit)
Please help I want make a script that when player touches the brick their tools rest. Thanks
(first off, use code blocks and more depth into your question next time)
i tested it, and it works fine, until you do so while HOLDING a tool, the reason for this is because whenever a tool is being held, its moved out of the backpack, and into the character, so be sure to deal with that too
also :connect() is depracted, use :Connect() same for :remove(), use :Destroy()
function Touch(hit) if hit and h.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then game.Players[h.Parent.Name].Backpack:ClearAllChildren() local CharTool = FindFirstChildOfClass(_HopperBin_) or h.Parent_FindFirstChildOfClass(_Tool_) if CharTool then CharTool:Destroy() end end end script.Parent.Touched:Connect(Touch)
Closed as Not Constructive by Leamir and User#21908
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?