Problem with changing UI elements (too quickly?)

Hi, I’m trying to make an inventory system that is updated whenever a user picks up an item. However, the UI does not update until an item is selected in the explorer pane. I’ve tried several solutions, like changing a property and reverting it, waiting before changing properties, but it hasn’t been working. Below, I’ve attached a video of me attempting to pick up a stick but it not appearing in the inventory.

I’m sure if this is a problem with my programming, as the item shows up in the Roblox explorer and in the table containing the inventory, but it does not show on screen. This could definitely be a Roblox bug.

As a side note, I am supposed to be able to pick up the item in the inventory, but I cannot as the game is not recognizing anything is there.

Is there any solution to my problem, or is this a Roblox bug? Any help is much appreciated!

Myself (and probably others) can not really help you problem solve the issue unless you show us your code. It would be greatly appreciated if you can show some level of code to help diagnosis your issue.

This is the code that updates the inventory.

UpdateInventory = function()
	print("Hotbar refresh")
	for i, v in pairs(SlotDesignation) do
		print(i, v)
		local slot = script.Parent.Player.Inventory:FindFirstChild(tostring(i))
		local amount = script.ItemAmount:Clone()
		amount.Parent = slot 
		if ItemsInInventory[v] > 1 then
			amount.Text = tostring(ItemsInInventory[v])
			amount.Text = ""
		--[[local image = script.Image:Clone()
		image.Parent = slot
		gotta save stuff for later!
		local image = script.NoImage:Clone()
		image.Parent = slot
		image.Text = v

Clear Inventory function:

local function ClearInventory()
	for i = 1, SlotAmount do
		local Slot = script.Parent.Player.Inventory:FindFirstChild(tostring(i))
		local NoImage = Slot:FindFirstChild("NoImage")
		local AmountLabel = Slot:FindFirstChild("ItemAmount")
		if NoImage then NoImage:Destroy() end
		if AmountLabel then AmountLabel:Destroy() end

The updateHotbar() function doesn’t have much to do with the inventory itsself. I’m most concerned about the UpdateInventory function. Also, the reason why it’s defined as UpdateInventory = function() is becuase it is defined earlier in the code can it can be used by later functions, and it can use earlier functions than where it is defined.

I still haven’t found a solution.

It might have to do with LocalScripts not updating the server, but I am not sure as I don’t know where you placed those scripts

The localscripts are inside the UI that contains the inventory.

Is anything being handled with the server? If so you might need to use FireServer()

UI should only ever be handled on the client, unless there’s something important in that UI that requires a server check.

The only thing that is being handled on the server is the inventory updating. The UI gets refreshed when the inventory changes. The UI is entirely on the client, no server scripts.

You should do a RemoteEvent with FireServer() to update the value, this is so the server detects

Ah! I figured it out. Apparently updating a UI whilst it’s disabled doesn’t work. I’ll submit a bug report later.

1 Like

Turns out the problem has popped up again, this time with buttons inside of frames. Basically, the same code as the previous problem. I tried the solution that worked last time, but it isn’t working. Yay. Does anyone know how to fix this? Or is this something on Roblox’s end that is completely out of my control?

Still looking for a solution to the problem.

I feel like this is a roblox bug probably, as I had seen someone else face a pretty similar bug too. And it worked when they selected the item in explorer.

i recommend submitting a bug report to Roblox.