Brick That Disables Tools

Hello everyone, I made some cool vehicles in blender, but every time I select a tool while in a vehicle, it makes the vehicle lag out, so can someone help with a script that disables tools when the brick is touched and gives them back when it is not being touched. I am short on time so please reply quick!

1 Like

Just use the Touched event to disable/delete the tools, along with a loop.

Example code:

-- NOTE: The following code is only to disable tools after the car is touched
local brick = workspace.Brick

brick.TouchEnded:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        for i, item in pairs(player.Backpack:GetChildren()) do
            if item:IsA("Tool") then
                item:Destroy()
            end
        end
    end
end)

To add the tools back into the player’s backpack, just clone them from a folder in ServerStorage or something; I’m not too sure about that one.

2 Likes