There are probably a lot more to come with my Universal Inventory Script, but right now I just need to focus on one issue. Cloning the Inventories into the proper places. There are two types of Inventories, inventory
; located in player
, & carrierInventory
; located in character
.
inventory
clones into player
but carrierInventory
doesn't clone into the character
. The Script is also supposed to dispose of itself once finished cloning, it appears it's a silent output issue judging by the Script obviously not following through with the disposal command, of which isn't interrupted by anything.
I can't seem to find the issue, can you?
Players.simplealgorithm.PlayerScripts.pickUpItem:46: attempt to index upvalue 'carrierInventory' (a nil value)
I moved the parent to starterCharacter and I got this
'Something unexpectedly tried to set the parent of setInventories to NULL while trying to set the parent of setInventories. Current parent is carrierInventory.'?
local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:wait() if (character) then local inventory = script:FindFirstAncestor("inventory") local carrierInventory = inventory:WaitForChild("carrierInventory") if not player:FindFirstChild("inventory") then inventory:Clone().Parent = player player:FindFirstChild("inventory"):ClearAllChildren() elseif not character:FindFirstChild("carrierInventory") then carrierInventory:Clone().Parent = character character:FindFirstChild("carrierInventory"):ClearAllChildren() end end script:Destroy()
Thanks!
Okay so the answer to your first issue of why carrierInventory
wasn't cloned into character
was because you put that in an elseif
block. This error makes the code either clone inventory
into player, or if there's already an inventory
there, it clones carrierInventory
into character
. It only does one or the other. In short, just change that elseif
to if
.
I don't know why the second issue is occurring, but it might be because of the first issue. If the script still being there still bothers you after the first fix, you can comment on my post for more help, or you can maybe try to disable the script using script.Disabled = true
and that might help a bit.