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

I need help with custom inventory gui, and equip system, help?

Asked by
Blodze 0
5 years ago

Ok so i've looked and tried scripts for inventory script but didnt find any so please help. This is the gui: ! On the right is the items ( It's like the basic inventory but the buttons at the right is the backpack ok. And when a item is equip the item will be on the left side on the character. The item gets placed on a certain place depends on the item. I have helmet, armor, weapon, pants. So i want the script to know that if the item that got equipped is a helmet. Helmet & image gets placed over the head on the character. And i want that with all over the character if a item is equipped. Such as helmet goes on head on the character gui and armor on the torso gui and more yea. I've already created a button that opens the inventory gui but i haven't found the solution for the inventory itself.


I've looked and tried for ages and i've never found a solution to this problem. I'd really appreciate if someone could help me with this script.

0
This shouldn't really be that complicated if you use the ChildAdded event for every place that an item could be parented to. All you would have to do after that is check if change the image if its a helmet, or check if the inventory slot is taken and move on until it finds an empty one. cmgtotalyawesome 1418 — 5y
0
^I meant object, not "place" cmgtotalyawesome 1418 — 5y
0
How are you doing that Blodze 0 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Your inventory system should have values that tell you it's a helmet (or whatever) and then you should be able to move that to the correct place.

Lets say I have two items and the player clicks one. How do I know it's a helmet?

local items = {
    Item1 = {
        Class = 'Helmet',
        Protection = 1,
        Image = 'rbxasset://1111'
    },
    Item2 = {
        Class = 'Armor'
        Protection = 5000,
        Image = 'rbxasset://5555'
    },
}

Well we create a variable for the item called Class. If I want to check if it's a helmet, I would just get the item and check if it's class is correct.

local clickedItem = 'Item1'

if (items[clickedItem].Class == 'Helmet') then
    --this item is a helmet
end

I used dictionaries for this example, this isn't the only way to store items. You could use tables and just check the positions of a table. Once you check it, you can easily just set the helmet in the correct place.

If you don't understand, I recommend either learning more about scripting, getting a scripter to actually do it for you, or selling your UI. Good luck!

0
How do i make a table that changes the items position. So i have the item inside of the gui as backpack instead of roblox's backpack? Blodze 0 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I'm going to attempt to give you an answer that gives you a better idea than the last one in hopes that you don't have to hire anyone or sell your UI. In this script I'm going to assume that you're parenting the armor pieces to your character (you can change that if its wrong very easily and I'll make sure to comment where to change).

game.Players.PlayerAdded:Connect(function(plr)
    repeat wait() until plr.Character end
    plr.Character.ChildAdded:Connect(function(item)
        --[[If your items are not stored in the character, plr.Character to the actual parent.]]
        if item.Class == "Helmet" then
            -- change the picture of the helmet slot
        end
        if item.Class == "Boots" then
            -- same thing but with the boots slot
        end
        --etc.
    end)
    --[[ I also noticed that you have a weapon slot, due to the fact that weapons are added to the Backpack and not the character model, we will need to connect the same function there.]]
    plr.Backpack.ChildAdded:Connect(function(item)
        if item.Class == "Sword" then
            -- same thing with a sword
        end
        -- also add other types of weapons if you have any.
    end)
end)

I hope that this was readable with the long comments and that it helped you out to the point of maybe being able to finish it. Good luck!

0
How does this change anything with the gui, will the items take the gui's place?, i have like slot1, slot2, slot3...and more but you have to script so the item gets placed on a certain place with help of tables i think. How? Blodze 0 — 5y
0
Like dungeon quest's inventory system.. please help me with the (whole script) Blodze 0 — 5y

Answer this question