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

Is it possible to limit your inventory? [closed]

Asked by 6 years ago
Edited 6 years ago

I am making a game with someone and it's kinda an RPG and apoc thing. I want people to only be able to hold a single gun, how do I do that?

0
You can remove the default backpack with “StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)” and make your own ABK2017 406 — 6y
0
It's not necessary to make an entire inventory on your own. Optikk 499 — 6y
0
Only a few lines of code are really needed to allow only one item Optikk 499 — 6y
0
Destroy the item in backpack -> add the new item Vulkarin 581 — 6y

Closed as Too Broad by zblox164, Gey4Jesus69, green271, and Void_Frost

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

2 answers

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

What you can do is you can check whenever the player's backpack's children have changed, then go from there!

The "ChildAdded" event is perfect for checking if something has been added.

game.Players.PlayerAdded:Connect(function(player) -- when the player joins the game. "player" is the player
    player:WaitForChild("BackPack").ChildAdded:Connect(function(object) --object being that new item added
        if object.Name ~= "put the name of your gun here" then --if not the gun, then...
            object:Destroy() --remove it!
        end
    end)
end)

Please leave an upvote if this helped you out! Comment if something was wrong

Ad
Log in to vote
0
Answered by 6 years ago

You have to attempt the coding before asking a question.