Price is not a valid member of ImageButton "Jawbreaker"

  1. What do you want to achieve? Keep it simple and clear!
    Need to change text to a items price value.

  2. What is the issue? Include screenshots / videos if possible!
    Price is not a valid member of ImageButton “Krabby Patty”

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Devfourms

Local Script Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Items = ReplicatedStorage:WaitForChild("Gears"):GetChildren()

local Container = script.Parent.Container
local itemFrame = Container.ItemsFrame

local shopUI = script.Parent
local exit = shopUI.Container.Exit

local player = Players.LocalPlayer

local PurchaseSound = shopUI.Sounds.Purchase
local ErrorSound = shopUI.Sounds.Error

function updateItems()
	for i, item in pairs(Items) do
		-- Find any old buttons
		local oldButton = itemFrame:FindFirstChild(item.Name)
		if oldButton then
			oldButton:Destroy()
		end
		
		local newButton = itemFrame.TemplateButton:Clone()
		newButton.Name = item.Name
		if item.Config.Price.Value and newButton.Price then
			newButton.Price = item.Config.Price.Value
		end
		
		newButton.TowerName.Text = item.Name
		newButton.Image = item.Config.Image.Texture
		newButton.LayoutOrder = item.Config.Price.Value
		newButton.Parent = itemFrame
		newButton.Visible = true
		
		newButton.Activated:Connect(function()
			local coinLeaderstats = player:WaitForChild("leaderstats").Coins
			if coinLeaderstats.Value >= item.Config.Price.Value then
				--coinLeaderstats.Value -= item.Config.Price.Value
				
				local remoteItem = item.Config.Price
				ReplicatedStorage.Remotes.SaveData:FireServer(remoteItem)
				if item then
					ReplicatedStorage.Remotes.ShopItemGiver:FireServer(item)
				else
					warn("no item or something")
					ErrorSound:Play()
				end
				
				PurchaseSound:Play()
			else
				-- error
				warn("Not enough coins!")
				ErrorSound:Play()
			end
		end)
	end
end

local function toggleShop()
	shopUI.Container.Visible = not shopUI.Container.Visible
	if shopUI.Container.Visible then
		updateItems()
	end
end

local function setupShop()
	local prompt = Instance.new("ProximityPrompt")
	prompt.RequiresLineOfSight = true
	prompt.ActionText = "Shop"
	if workspace.Shop:WaitForChild("ShopPart") then
		prompt.Parent = workspace.Shop:FindFirstChild("ShopPart")
	end
	
	prompt.Triggered:Connect(toggleShop)
	exit.Activated:Connect(toggleShop)
end

setupShop()

Explorer:
image
image

Its actually:

newButton.Price.Text= tostring(item.Config.Price.Value) 
1 Like

Thanks alot. it works now and the prices are show.

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