I'm currently trying to make a backpack/inventory system with keypress and clicking but the server script doesn't work with keypress and the local script has the following error:
Local Script Error:
Players.WyattagumsBackUp.PlayerGui.BackpackGUI.Background.a.equipbutton.LocalScript:24: attempt to index upvalue 'itm' (a nil value)
Local Script:
local lab = script.Parent.Parent.label
local num = script.Parent.Parent.number
local but = script.Parent
local pak = script.Parent.Parent.Parent.Backpack
local itm = script.Parent.Parent.item.Value
local plr = game.Players.LocalPlayer
local chr = plr.Character
local eqp = script.Parent.Parent.equipped.Value
function onClicked()
if eqp == false then
itm.Parent = chr
eqp = true
elseif eqp == true then
itm.Parent = pak
eqp = false
end
end
script.Parent.MouseButton1Down:connect(onClicked)
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.One then
if eqp == false then
itm.Parent = chr
eqp = true
elseif eqp == true then
itm.Parent = pak
eqp = false
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
The server script works perfectly with the clicking but not the keypress, whilst the local script sends out the said error...
Server Script:
local lab = script.Parent.Parent.label
local num = script.Parent.Parent.number
local but = script.Parent
local pak = script.Parent.Parent.Parent.Backpack
local itm = script.Parent.Parent.item.Value
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local chr = plr.Character
local eqp = script.Parent.Parent.equipped.Value
function onClicked()
if eqp == false then
itm.Parent = chr
eqp = true
elseif eqp == true then
itm.Parent = pak
eqp = false
end
end
script.Parent.MouseButton1Down:connect(onClicked)
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.One then
if eqp == false then
itm.Parent = chr
eqp = true
elseif eqp == true then
itm.Parent = pak
eqp = false
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
Both scripts are relatively the same, except for the one change which is the "local plr"
Here is an image of the system paths: https://imgur.com/MoSPTkR
If you would require further explanation/information then please do respond to this post on your concerns!

8 comments
How would I directly implement that into my script?
Lemme add it.
k
Edited.
oh okay~ I'm so silly for making such an insultingly benign mistake!
This is a mistake I've done, but hey, it's a sign of learning!
Dully note that we forgot to add ".Value" to the itm, so itm.Parent would be itm.Value.Parent
itm.Value.Parent would return itm.