So I’m trying to make an inventory system, and I’m getting an error.
LocalScript:
EquipButton.Activated:Connect(function()
if SelectedTemplate ~= nil then
local Item = Inventory:WaitForChild(SelectedTemplate.Name)
if Item ~= nil then
DisplayFrame.Visible = false
for i, Object in pairs(ItemDisplay:GetChildren()) do
if not Object:IsA('UICorner') then
Object:Destroy()
end
end
local Result = EquipItem:InvokeServer(Item:Clone())
end
end
end)
ServerScript:
ReplicatedStorage.Remotes.EquipItem.OnServerInvoke = function(Player,Item)
if not Player.Backpack:FindFirstChild(Item.Name) then
Item.Anchored = false
local Tool = Instance.new('Tool', Player.Backpack)
Tool.Name = Item.Name
Item.Parent = Tool
Item.Name = 'Handle'
return 'Equipped'
end
end
Nevermind, ignore my last reply. That error message wouldn’t make sense with what I suggested. I believe you’re getting this error because you’re attempting to Clone Item on the client, and then you’re trying to reference it on the server meaning Item is nil. To confirm this, on your server side, make your first line print(Item). I’m willing to bet it’s going to print nil. Instead try passing the name of the item you wish to clone to the server or a reference to the item, then have the server clone it.
Is there only one of the item in the game? If so your not cloning it rather you are moving the only one. So all players may spawn and will pass :WaitForChild() for after that once a single player uses the item, it is no longer there. Therefore causing it to nil for other players.