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

How to make this script remove all tools from backpack when you teleport?

Asked by 4 years ago
Edited 4 years ago



local part = workspace.Cabin local plr = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() local LowerTorso = plr.Character:FindFirstChild("HumanoidRootPart") if LowerTorso then LowerTorso.CFrame = CFrame.new(part.CFrame.p) end end) script.Parent.MouseButton1Click:Connect(function(Click) script.Parent.Parent.Parent.Enabled = false end) local human = part.Parent:FindFirstChild("Humanoid") --Check if it is player local player = game.Players:GetPlayerFromCharacter() --Get actual player object if human then for i,v in pairs (part.Parent:GetChildren()) do --Look inside player if v:IsA("Tool") and v.Name == "Lantern" then --If they are holding the tool we want v:Destroy() end end for i,v in pairs (player.Backpack:GetChildren()) do if v.Name == "Lantern" then v:Destroy() --Search backpack for tool as well end end end
0
easy, check the character or the players backpack VVoretex 146 — 4y
0
How would I do that though? Synavant 6 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I'm confused on why you did "human = part.Parent:FindFirstChild("Humanoid")". Part is your variable name for the cabin. By the way, you don't have to destroy the tools. Just clear the backpack like this:

local part = workspace.Cabin
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    local LowerTorso = plr.Character:FindFirstChild("HumanoidRootPart")
     if LowerTorso then
        LowerTorso.CFrame = CFrame.new(part.CFrame.p)
    end
end)

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Parent.Enabled = false
end)

    if plr then
    player.Backpack:ClearAllChildren() -- Clears backpack
end

Hope this helps!

0
It didn't work, could you maybe explain how or where I would use that script? Synavant 6 — 4y
0
Yeah, I just edited the Script. I included your original one so you know where to put it. AntiWorldliness 868 — 4y
Ad
Log in to vote
0
Answered by
WishXVI 94
4 years ago

So you could use

game.Players.PlayerYouWant.BackPack:ClearChildren()

Answer this question