Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

clicked is a number value??

Asked by
BiIinear 104
5 years ago

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.

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

Because it is a number value. Don't be silly.

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?

0
shut up incapoop u nrd Fifkee 2017 — 5y
0
nerd nerd nerd nerd nerd TheeDeathCaster 2368 — 5y
0
Incapaxx, thanks. I was really tired that day. Also, who are these 2 trolls? Why are they allowed on this platform? BiIinear 104 — 5y
Ad

Answer this question