Why won't my inventory script work?

I’m trying to make it so if you click on a button it sets other text to the stats of the button clicked, but for some reason it won’t work, it isn’t even throwing an error. Could someone please help?

This is all in a local script inside of an ImageButton

local itemStats = require(game.ReplicatedStorage.itemStats)

local frameHolder = game.StarterGui.Inventory.Back.StatsFrame
local itemPreview = frameHolder:WaitForChild("ItemPreview")
local durabilityTitle = frameHolder:WaitForChild("Durability")
local itemTitle = frameHolder:WaitForChild("itemTitle")
local damageTitle = frameHolder:WaitForChild("DamageTitle")

local mainButton = script.Parent

local currentItem = mainButton:WaitForChild("CurrentItem")

mainButton.MouseButton1Down:Connect(function()
	if script.Parent.Visible == true then
		if currentItem.Value == "Pickaxe" then
			itemPreview.Image = itemStats.WeaponStats.Pickaxe.ImageId
			durabilityTitle.Text = itemStats.WeaponStats.Pickaxe.Durability
			itemTitle.Text = itemStats.WeaponStats.Pickaxe.ItemName
			damageTitle.Text = itemStats.WeaponStats.Pickaxe.Damage
		end
	end
end)```

You are using startergui. Use the player’s PlayerGui.

2 Likes

oh wow, i forgot about that, thank you so much!

if your script is inside startergui, roblox automatically sets the scripts parent to playergui!

1 Like