So I have this script:
“key” is the number that the player pressed, and ThingOccupying is a string value that contains the name of the tool occupying that slot. The images that represent the slots are named slot1,slot2,slot3, etc.
However, this line gives me an error:
Players.nicknickphoenix.PlayerGui.ScreenGui.LocalScript:43: attempt to index nil with 'Value'
How should I fix it so that it will equip the tool that is supposed to be equipped?
The error suggests that
Also, you shouldn’t equip tools on the client due to replication issues. Try using a RemoteEvent to tell the server to equip the tool.
So, “key” is the number that the player pressed. What exactly is it? Is it a NumberValue or Enum.KeyCode or something else?
We need to know this, since the only thing the error message is saying is that "there is no ‘ThingsOccupying’ inside of ‘key’
local mouse = player:GetMouse()
to get the key
Oh yeah, forgot about that however ThingOccupying shouldn’t be nil
(As you can see, it’s a string value inside all the slots)
In this case, “key” is either something like MouseButton1 or an enum thing idk, but it does not contain ThingsOccupying for sure.
when I do
In the output, I get “slot1”, which is the name of the image button and slot1.ThingOccupying.Value should be the name of the tool, but instead it says “attempt to index nil with ‘Value’”
Oh I think I got it. It’s a simple logic error. This should maybe work:
Replace your script’s line that caused the error with this.
Thanks, however it still did not work
Did you get any errors? If yes please tell me what the error was.
I just got the same error again
Send me a screenshot of the player’s backpact in Explorer please.
Actually I managed to fix it, I changed the line to