I have my own inventory and I was wondering is it possible so when the 1 button is pressed it equips their item in their backpack? I have done all the no. stuff, removed robloxs one and made it so when they click a button a sword is put in their backpack, but I don't know how to make it so its equipped. Is there something like :Equip()
or something?
script.Parent.StartGui.ClassFrame.Buttons.PlayKnightButton.MouseButton1Down:connect(function(onClick) script.Parent.Inventory.MainFrame.InvSpace.Inv1.Image = "rbxasset://Textures/Sword128.png" local Item = game:GetService("ReplicatedStorage").Weapons.Sword Item:Clone().Parent = game.Players.LocalPlayer.Backpack Item:Clone().Parent = game.Players.LocalPlayer.StarterGear char:WaitForChild("Humanoid"):EquipTool(player.Backpack:GetChildren()) end)
Yes, there is a method in Humanoid called EquipTool()
. It's basically the same as parenting a tool to the player's character. For hopperbins, I'm not too sure but this definitely works for tools.
Below is an example of how to equip a tool after 5 seconds of when you spawn:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) wait(5) char:WaitForChild("Humanoid"):EquipTool(player.Backpack.Tool) --Change Tool to the name of the Tool. end) end)
Method page: http://wiki.roblox.com/index.php?title=EquipTool_(Method)
EDIT:
script.Parent.StartGui.ClassFrame.Buttons.PlayKnightButton.MouseButton1Down:connect(function() script.Parent.Inventory.MainFrame.InvSpace.Inv1.Image = "rbxasset://Textures/Sword128.png" local Item = game:GetService("ReplicatedStorage").Weapons.Sword:Clone() item.Parent = game.Players.LocalPlayer.Backpack local item2 = game:GetService("ReplicatedStorage").Weapons.Sword:Clone() item2.Parent = game.Players.LocalPlayer.StarterGear game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):EquipTool(item) end)