How to get object that is in objectvalue

hi, i have an objectvalue in the players gui that points to an object that is in replicatedstorage

-- equip item
local fake = nil
events.EquipItem.OnServerEvent:Connect(function(fake, slot, localPlayer)
	local objectVal = slot:FindFirstChild("Item")
	local objectValValue = objectVal.Value
	local objectFolder = game.ReplicatedStorage.InventoryItems:FindFirstChild(localPlayer.Name)
	objectFolder:FindFirstChild(objectValValue).Parent = localPlayer.Character
end)

and i’m trying to get the actual object that the objectvalue is referring to, and set its parent. but apparently findfirstchild can only find strings?
image

it might be that its late at night and im missing something but i cant figure out how to do this

What you’re doing is essentially passing an object into the :FindFirstChild() method. Not the name of the instance, which is what it expects. The objectValValue holds the instance, and not the name. Therefore if you just do :FindFirstChild(objectValValue.Name), that should fix it.
(assuming I understand what your issue is - based off of the error image you attached, that’s what I’m guessing the problem is)

hi, thanks for your reply, but is there any way to get the specific object that is in the value? because i would have multiple objects of the same name so that is why im using an objectvalue to pinpoint to that specific one

Wouldn’t objectValValue.Parent = NewParent be what you’re looking for? That is, if you’re trying to change the parent of the object in the objectValue - which is what you’re doing right?

oh yeah it is, for some reason i thought you had to get the location using the value or something and couldnt just use the value, idk why. maybe it is a bit too late to be doing this - anyways thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.