So I've been making this custom inventory for the past week. So far the progress is good, but this error that really confuses me prevents me from continuing to develop the inventory. "Players.BiIinear.PlayerGui.Inventory.Frame.SlotFrame.Slot01.LocalScript:8: attempt to index local 'clicked' (a number value)" I'm not even sure how clicked, the player that fired the script can turn out to be a number value...
wait(5) local item = script.Parent.ItemNameValue.Value local player = game.Players.LocalPlayer --Equip script.Parent.MouseButton1Down:Connect(function(clicked) if script.Parent.ItemNameValue.Value ~= 'nil' then local tool = clicked.Backpack[script.Parent.ItemNameValue.Value] clicked.Character.Humanoid:EquipTool(tool) else end end)
'ItemNameValue.Value' means the name of the item in the slot. Any help would be greatly appreciated. Like I said, this makes no sense to me.
The MouseButton1Down
listeners get the X and Y 2D coordinates of the mouse click. clicked
is the X coordinate. It wouldn't make any sense at all for the listeners to get a reference to the player as an argument, as the script is local and you know who the local player is. You have a player
variable, which points to the local player, so why didn't you use it?