Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

clicked is a number value??

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

✓ Accepted answer

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?

3 comments

0

shut up incapoop u nrd

0

nerd nerd nerd nerd nerd

0

Incapaxx, thanks. I was really tired that day. Also, who are these 2 trolls? Why are they allowed on this platform?

This discussion is preserved as it was. New answers, comments, and votes are closed.