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
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!
So you could use
game.Players.PlayerYouWant.BackPack:ClearChildren()