I’m making a backpack, but when I try to put the tool back in the backpack from the plr, it tells me I am indexing nil with Parent. I printed the tool name below and it’s the same name but it’s still showing as nil. My current code:
local equipped = false
local plr = game.Players.LocalPlayer
local backpack = plr:WaitForChild("Backpack")
script.Parent.MouseButton1Click:Connect(function()
local tool = backpack:FindFirstChild(script.Parent.Text)
if equipped == false then
tool.Parent = plr.Character
print(tool.Name)
print(tool.Parent.Name)
equipped = true
elseif equipped == true then
tool.Parent = backpack
equipped = false
end
end)
Were you referring to the tool.Parent = plr.Character or the tool.Parent = backpack in your earlier post? If you were talking about the former, then it works. Also, I did use remote event to connect to the server, I know how to use it.
Variables don’t work like that. Once they’re defined, they’re like that. They stick with their values, and they don’t keep checking in that place to define it again like that.