UI Showing but not parenting right

In another script when the player buys a hat it sets the value to true, and it adds a box to the inventory. The problem i’m having is its adding it to the inventory but it is not showing parented under the inventory scrolling frame. But its supposed to be parenting there.

local player = game.Players.LocalPlayer
local hats = player:WaitForChild("hats")
local scrollingFrame = script.Parent.Inventory.ScrollingFrame

local function addbox(hat, name, imgid)
	if hat.Value and not scrollingFrame:FindFirstChild(name) then
		local boxClone = script.Parent.Inventory.ScrollingFrame.Box:Clone()
		boxClone.Name = name
		boxClone.Parent = scrollingFrame
		boxClone:FindFirstChild("Hat").Image = "rbxassetid://"..imgid
		boxClone.BackgroundTransparency = 1
		boxClone.ImageTransparency = 0
	end
end

local function updateHat(hat, name, imgid)
	addbox(hat, name, imgid)
	
	hat:GetPropertyChangedSignal("Value"):Connect(function()
		if hat.Value then
			addbox(hat, name, imgid)
			local box = scrollingFrame:FindFirstChild(name)
			if box then
				box:FindFirstChild("Hat").Image = "rbxassetid://"..imgid
				box:FindFirstChild("Hat").ImageTransparency = 0
			end
		else
			local box = scrollingFrame:FindFirstChild(name)
			if box then
				box:Destroy()
			end
		end
	end)
end
wait(0.1)
updateHat(hats.ValkyrieHelmOwned, "ValkyrieHelmOwned", 12560784108)
updateHat(hats.SummerHatOwned, "SummerHat", 12560635735)
updateHat(hats.BeanieHatOwned, "BeanieHat", 67890)
updateHat(hats.BlackDominus, "BlackDominus", 12560783170)
updateHat(hats.ConeOwned, "Cone", 12560659456)
updateHat(hats.DominoCrownOwned, "DominoCrown", 12560638623)
updateHat(hats.DominusOwned, "Dominus", 12560641835)
updateHat(hats.MaskOwned, "Mask", 12560644217)
updateHat(hats.PartyHatOwned, "PartyHat", 12560650596)
updateHat(hats.RGBTopHatOwned, "RGBTopHat", 22222)


wait(0.1)
updateHat(hats.SkyBlueSparkleTimeFedoraOwned, "Sky Blue SparkleTime Fedora", 12560447910)
updateHat(hats.TopHatOwned, "TopHat", 12560630631)
updateHat(hats.VROwned, "VR", 12560662543)
updateHat(hats.ValkOwned, "Valk", 55555)
updateHat(hats.AlienOwned, "Alien", 12591797248)
updateHat(hats.BoneyardOwned, "Boneyard", 4581014746)
updateHat(hats.GreenPumpkinHeadOwned, "Green Pumpkin Head", 12591825917)
updateHat(hats.MoonSeeingStarsOwned, "Moon Seeing Stars", 12591802971)
updateHat(hats.BlackSparkleTimeFedoraOwned, "Black SparkleTime Fedora", 12560453323)
updateHat(hats.BlueSparkleTimeFedoraOwned, "Blue SparkleTime Fedora", 55555)
updateHat(hats.OrangeSparkletimeFedoraOwned, "Orange SparkleTime Fedora", 12560457268)
updateHat(hats.PurpleSparkleTimeFedoraOwned, "Purple SparkleTime Fedora", 12560437036)
updateHat(hats.RedSparkletimeFedoraOwned, "Red SparkleTime Fedora", 12560408142)
updateHat(hats.TealSparkleTimeFedoraOwned, "Teal SparkleTime Fedora", 12560442181)

wait(0.1)
updateHat(hats.FlowerOwned, "Flower", 12591687213)
updateHat(hats.KingKongOwned, "King Kong", 12591792575)
updateHat(hats.LOLMOONOwned, "LOLMOON", 55555)
updateHat(hats.TentaclesOwned, "Mrs. Tentacles", 12591801870)
updateHat(hats.TreeSpiritOwned, "Tree Spirit", 12610156100)

May you screenshot the problem so I can understand the situation a bit more?

I figured it out. There was an issue in the script that reparented it.

1 Like

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