Hello how are you? I’m having problems with my code, it serves to load an item and put it in the player’s inventory
This is my code:
event = game.ReplicatedStorage.UiWorldEvent.GetIten
event.OnServerEvent:Connect(function(player, id)
-- id is the item id
local getservice = game:GetService("InsertService")
local loaded = getservice:LoadAsset(tostring(id))
local item = getservice:Insert(loaded)
item.Parent = player.Backpack
end)
And when it runs, it resumes the following error:
15:26:42.600 item ID is:116040828 - Cliente - LocalScript:9
15:26:42.814 ServerScriptService.UIWorldEventsScript.itensgiver:7: attempt to index nil with 'Parent'