Help with script from tutorial

here’s the script:

local Plots = game.Workspace.Plots

local TemplateWarehouse = game.Workspace.TemplateWarehouse

game.Players.PlayerAdded:Connect(function(player)
	for _, plot in Plots:GetChildren() do
		if plot:GetAttribute("Taken") then continue end
		plot:SetAttribute('Taken', true)
		plot:SetAttribute('Owner', player.UserId)
		
		print('Plot has been given to '..player.Name..'!')
		
		local ItemsFolder = Instance.new('Folder')
		ItemsFolder.Name = 'Items'
		ItemsFolder.Parent = plot
		
		local ButtonsFolder = Instance.new('Folder')
		ButtonsFolder.Name = 'Buttons'
		ButtonsFolder.Parent = plot
		
		local TemplateButtons = TemplateWarehouse.Buttons:Clone()
		TemplateButtons.Parent = workspace.TemplateWarehouse
		print(TemplateButtons)
		local TemplateItems = TemplateWarehouse.Items
		
		for _, Button in TemplateButtons:GetChildren() do
			local RelativeCFrame = TemplateWarehouse:GetPivot():ToObjectSpace(Button:GetPivot())
			Button:PivotTo(plot:GetPivot():ToWorldSpace(RelativeCFrame))
			
			Buttons.Button["InvisablePart"].Touched:Connect(function()
				local player = game.Players:GetPlayerFromCharacter(hit.Parent)
				if not player then return end
				if plot:GetAttribute('Owner') ~= player.UserId then return end
				
				local itemToUnlockId = Button:GetAttribute('IdOfItemToUnlock')
				if not itemToUnlockId then warn ('You forgot to add an IdOfItemToUnlock attribute') return end
				
				for _, item in TemplateItems:GetChildren() do
					if item:GetAttribute('Id') ~= itemToUnlockId then continue end
					local itemClone = item:Clone()
					local itemCFrame
					
					if itemClone:IsA('Model') then
						itemCFrame = itemClone:GetPivot()
					elseif itemClone:IsA('BasePart') then
						itemCFrame = itemClone.CFrame
					end
					local relativeItemCFrame = TemplateWarehouse.CFrame:ToObjectSpace(itemCFrame)
					
					if itemClone:IsA('Model') then
						itemClone:PivotTo(TemplateWarehouse.CFrame:ToWorldSpace(relativeItemCFrame))
					elseif itemClone:IsA('BasePart') then
						itemClone.CFrame = TemplateWarehouse.CFrame:ToWorldSpace(relativeItemCFrame)
					end
					
					itemClone.Parent = ItemsFolder
				end
			end)
			Button.Parent = ButtonsFolder
		end
		TemplateButtons.Parent = plot
		break
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	for _, plot in Plots:GetChildren() do
		if plot:GetAttribute("Owner") then continue end
		if plot:GetAttribute("Owner") ~= player.UserId then continue end
		plot:SetAttribute('Taken', nil)
		plot:SetAttribute('Owner', nil)
		
		print('Plot has been removed from '..player.Name..'!')
		break
	end
end)

i don’t know how to fix the button part and the touch part


image

Also the tutorial i’m following is from AlvinBlox on YouTube.
Link:
Roblox Tycoon Scripting Tutorial (Part 2)

Buttons has an orange underline meaning it wasn’t predefined, anyways you’re looping through a table

Instance:GetChildren() returns a table with every instance under the instance it’s casted on

for index, instance in table do
 --Code
end

This block of code will iterate through the table, im this case being TemplateButtons:GetChildren() GetChildren() returns no index so it’s not important for this, a for loop will do the block of code for every instance in the table, instance serves as a variable for the iteration

It’s a lengthy explanation i know, just trying to make sure you understand, but just change Buttons.Button for Button