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.
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!
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!