Hello I am Ajoeb. I am new to scripting. I want to ask if anyone can help me with this eror. I have tried a lot of things still I can’t fix it.
Can you copy paste the code? Please, don’t use images instead of code.
The error says Item is nil, try to put
if Item then
-- continue the code
end
What should I use instead of StarterGear.
You can make a script where when the character spawns/respawns it will give him the Tool. Anything else will not work because StarterPack will give it to all the players.
Check if the item is exist with FindFirstChild()
Then clone it
I arleady said it, please read before posting.
Why all say the same thing i say?
This still wouldn’t fix his script though, the player will still not get the items.
Because Confige.Item.Value is nil
@OfficialAjoeb can you post a screenshot of your entire explorer, so we can see where everything is laid out?
That won’t help in anyway, try to see the script and figure out what’s happening there, if you can’t I would recommend to leave the discussion (not rude).
Anyway, I think that he’s trying to make a Mining Shop by the tutorial of one Youtuber like AlvinBlox, TheDevKing or others.
First of all!
Like our partner @TheTurtleMaster_2 already said, the StarterGear
isn’t avaible anymore on the player, you can’t clone something and parent it to something that doesn’t exist!
Second!
I should recommend to use tables to store different assets into this one, this will become more effective when trying to restore the item into the player when he dies, if that’ what are you trying to do.
Anyway, I’m just a noob programmer, you should ignore me or take my tip!
Have a nice day! - @Lil_SharkyBoy
It does matter, the problem is that Item is a not a child of configure. This has everything to do with the layout of the game, so I want to show him where it went wrong.
The reason you are experiencing that error is because the FindFirstChild(configurestuff) is returning nil. That or because you are setting the Parent of the returned instance from the clone in the same line as the clone is called.
I do that all the time and it works for me
Idk I think I recall doing that back in the day and getting errors.
This is not the problem, the problem is Confige.Item.Value is nil. What you said will not change anything.
Its not necessarily nil. It could be any value which isnt the name of a child of the items folder.
As the other posts stated, Item
is nil, causing the script to error. I dont have enough information to give a full on solution, but you should check the location of your items. Maybe you accidentally moved Items[Configure.Item.Value]
to somewhere else, maybe the item the player is requesting isnt even in the folder. If (and i mean If) your game isnt released to the public yet and youre using some DataStore system, you should do a data wipe and try again (ive had issues with this type of thing before and this fixed it). Thats all the advice i can give really.
What should I use instead of configure.item.value.
Keep it the same, the problem is in the folder the script cannot find configure.item.value
To reiterate, the problem is that either the script can’t find Configure.Item.Value
in ServerStorage, probably because they happen to have different names or the object just doesn’t exist, or Configure.Item.Value
is nil. Try adding print statements to see what exactly the issue is:
-
Add a print function to print
Configure.Item.Value
to see what exactly is wrong with it, as well as make a for loop that iterates over the items in ServerStorage and compare the names withConfigure.Item.Value
:print(Configure.Item.Value) for _, v in pairs(game.ServerStorage.Items:GetChildren()) do print(Configure.Item.Value, v.Name, Configure.Item.Value == v.Name) -- The 3rd printed value with either print "true" or "false", according to if Configure.Item.Value and the current item being iterated's name is the same end
But if Configure.Item.Value
is nil, it would probably error where the FindFirstChild part is. I’m not really sure, who knows ¯_(ツ)_/¯. We can only be sure of that after we test
@TheTurtleMaster_2 StarterGear is not deprecated, nor deleted and it can still be used. If it wasn’t able to be used, the script would error at that point. I wouldn’t see the need to remove it because it basically makes cloning tools upon respawn easier than just writing your own code for that