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

Can someone help me with this script. When I touch the brick it doesn't work? [closed]

Asked by
xOmqZaxk -45
6 years ago
Edited 6 years ago

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

0
don't get a random script from the internet, please post your broken script Leamir 3138 — 6y

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?

1 answer

Log in to vote
-1
Answered by 6 years ago

(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)
0
Thats not what he wants... he wants the tools to get reset like the player died, but not with killing him Leamir 3138 — 6y
Ad