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

How do I remove a tool without them having to reset?

Asked by 6 years ago

I'm trying to make a broom that destroys after a certain amount of hits and I'm working on the destroy script. I figured it out but the tool removes but the player needs to reset before it's removed, really don't want to have to kill the player each time.. Here's what I have:

local broomHealth = script.Parent.broomhealth.broomhealth.Value
local plrBackpack = game.Players.LocalPlayer.Backpack
while true do
    wait(10)
    plrBackpack:FindFirstChild("Broom")
    if broomHealth <= 0 then
        plrBackpack.Broom:Destroy()
    end
end

Thanks :)

1 answer

Log in to vote
0
Answered by 6 years ago

The thing is, if the person has that equipped, then the broom model is actually in their character model and not in their backpack. Try destroying the broom from the character model instead of the backpack.

If this is a local script you can do

local player = game.Players.LocalPlayer
local character = player.Character

character.Broom:Destroy()
Ad

Answer this question