Tycoon buy button not working

I am making a tycoon button purchasing system using attributes but when i try buying things it doesent work despite the attributes of the id and button being the same.
The attributes for both models are ‘1’

Purchase handler

local Purchases = script.Parent.Purchases:GetChildren()
local debounce = false
local TycoonFolder = Instance.new("Folder", game.ReplicatedStorage)
TycoonFolder.Name = script.Parent.Name





	for _, purchases in pairs((script.Parent.Purchases:GetChildren())) do
		purchases.Parent = game.ReplicatedStorage:FindFirstChild(script.Parent.Name)
		purchases:GetAttribute("Id")
	end
	
	
	for _, button in pairs((script.Parent.Buttons:GetChildren())) do
	button.ProximityPrompt.Triggered:Connect(function(player)
			for _, purchases in pairs((TycoonFolder:GetChildren())) do
			if player ~= script.Parent.Owner.Value then continue end
				local IdOfItem = button:GetAttribute("IdOfItem")
				local Id = purchases:GetAttribute("Id")
				
				print(Id)
				print(IdOfItem)
				
			if Id ~= IdOfItem then continue end
					
				
					print(1)
				
				local purchaseClone = purchases:Clone()
				purchaseClone.Parent = script.Parent
			end
		end)
         end

Owner Door:

script.Parent.Head.ProximityPrompt.Triggered:Connect(function(player)
	script.Parent.Head.ProximityPrompt:Destroy()
	if player ~= nil then
		local PlayerStats = game.ServerStorage.PlayerStats:FindFirstChild(player.Name)
		if PlayerStats ~= nil then
			local ownstycoon = PlayerStats:FindFirstChild("OwnsTycoon")
			if ownstycoon ~= nil then
				if ownstycoon.Value == nil then
					if script.Parent.Parent.Owner.Value == nil then
								script.Parent.Parent.Owner.Value = player
								ownstycoon.Value = script.Parent.Parent
								script.Parent.Claim.DisplayName = player.Name.."'s Tycoon"
								script.Parent.Head.Transparency = 0.6
								script.Parent.Head.CanCollide = false
							end
						end
					end
				end
			end
        end)

Any help would be greatly appriciated!

Which of the print statements in the Purchase Handler script fire? What do they output?

Are you sure that both Id and IdOfItem are of the same data type? One could be a number and the other could be a string, leading to issues:
image

You can modify your code to test this, by putting tostring() around both.
i.e.

local IdOfItem = tostring(button:GetAttribute("IdOfItem"))
local Id = tostring(purchases:GetAttribute("Id"))

I feel so stupid! Yes, one of the attributes must have been a string, I changed them both to be number values and it works! Thank you

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