So I am a complete noob with code, but I can at least somewhat figure out what stuff does. When I add a custom item into MH (submissions from toolbox), give it a unique ID and make sure it has all the things it should like the cost, itemtype, etc. and add a code to give me one of said item, it does nothing, just gives an error. Error I mentioned
Here's line 26-43 of the code that's throwing the error
function awardItem(Player, ItemId, Amount) Amount = Amount or 1 local Item = getItem(ItemId) if Item then if _G["Inventory"][Player.Name] ~= nil and _G["Inventory"][Player.Name][ItemId] ~= nil and _G["Inventory"][Player.Name][ItemId].Quantity ~= nil then _G["Inventory"][Player.Name][ItemId].Quantity = _G["Inventory"][Player.Name][ItemId].Quantity + Amount else _G["Inventory"][Player.Name][ItemId].Quantity = Amount end game.ReplicatedStorage.ItemObtained:FireClient(Player,Item,Amount) --game.ReplicatedStorage.Hint:FireClient(Player,"You were awarded "..Amount.." "..Item.Name..".",nil,Color3.new(0.5,0.5,0),"Obtained") game.ReplicatedStorage.InventoryChanged:FireClient(Player,_G["Inventory"][Player.Name],ItemId) return true else print("Could not find item") end return false end
Screenshot of it, sorry I couldn't fit it all
This is the code I tweaked to give me the custom item I added
{"testitem",Award,100076,1},
testitem is the code I need to put in the "secret code" box, Award is what tells the game it's an item, 100076 is the ID I gave the custom item (facemashed the ID when I made it), and 1 is the quantity. the original is the following
{"hyup",Award,400,1},
No matter what I do that I'm capable of doing, it never works. I compare it to the basic game's items and I see no difference. I can use some tweaked code to give myself anything else already in the game, but nothing that I add it seems.
If anyone has any ideas please let me know. If there isn't enough information I'll add anything else that may be relevant. This is my first post on any website, so my apologies if it looks like a mess, or if I take a while to reply.
I finally managed to figure out this issue myself. Can't believe it was something as dumb as something supposed to be IntValue being NumberValue.. If anyone else has issues, there's a "havenbook" at the Miner's Haven fandom that can really help. On the page, scroll down to "Actually Modding the Game" and locate the Havenbook link, it will redirect you to mega (file sharing service) where you can download the PDF.