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

Need a script about a character only having one gear at a time? [closed]

Asked by
FedrixYT -21
7 years ago

i need a script -- Once another gear is equipped then the gear that you originally had disappears. WHICH only allows person to have 1 gear at a time until new one is added to the backpack.So when the new one is added the one you had vanishes and you only have the gear you just got.

Closed as Not Constructive by TheeDeathCaster and Goulstem

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
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

Here, What this script will do, what i'm guessing you're asking for is, when a tool is added to player's backpack, any tool/tool he is currently using will be removed.

Place this code inside a localscript inside starterpack.

game.Players.LocalPlayer.Backpack.ChildAdded:connect(function(c)
    for _,v in pairs(game.Players.LocalPlayer.Backpack:GetChildren()) do
        if v~=c and v~=script and v:IsA("Tool") then
            v:Destroy()
        end
    end
    if workspace:FindFirstChild(game.Players.LocalPlayer.Name)~=nil then
        for _,vv in pairs(workspace:FindFirstChild(game.Players.LocalPlayer.Name):GetChildren()) do
            if vv:IsA("Tool") then
                vv:Destroy()
            end
        end
    end
end)

If you need any help please ask.

0
Providing code without an explanation is redundant and pretty much helps no one. Don't bother answering request questions anyways dude. Goulstem 8144 — 7y
Ad