My script doesn't run

  1. What do you want to achieve? Keep it simple and clear!
    I want to make A button system to my tycoon

  2. What is the issue? Include screenshots / videos if possible!
    the Script to buy doens’t run

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried do put the code to buy in another part of the script but the script doens’t run

local Tycoon = require(game:GetService("ServerScriptService").General)
local doro =  script.Parent.Doro
local text = script.Parent.Parent.BillboardGui.TextLabel
local EFteam = game:GetService("Teams")["Explosive Flash"]
local Buttons = require(game:GetService("ServerScriptService").Components.Buttons)
local EFtycoon = game:GetService("ServerStorage").Tycoons["Explosive Flash"]
local db = false
local EFwtyccon = script.Parent.Parent
local Owner = EFwtyccon:GetAttribute("Owner")

Tycoon.new(EFwtyccon)

doro.CanCollide = false

doro.Touched:Connect(function(player)
        Tycoon:Init(player,doro, text,EFteam,EFwtyccon)
	    Buttons:New(EFwtyccon)   
	if doro.Parent.Parent:GetAttribute("Owner")	~= nil
	then
		Buttons:Init("1buttonEF", EFwtyccon.Purchables)	 
		doro.CanTouch = false
		
end	
end)
while Owner ~= nil do
	print(5)
	Buttons:Buy1(EFwtyccon)
	Buttons:Sell()
	end

the button’s module script

ocal CollectionService = game:GetService("CollectionService")

local Buttons = {}
Buttons.__index = Buttons

function Buttons:New(tycoon)
	
	local self = setmetatable({}, Buttons)
	self.Tycoon = tycoon
	self.Owner = tycoon:GetAttribute("Owner")
	
end

function Buttons:Init(button1, wtycoon)
	
	for _, Button in pairs(CollectionService:GetTagged("StarterButton")) do
		if Button:GetAttribute("CurrentId")  == button1 then
			local Cbutton = Button:Clone()
			Cbutton.Parent = wtycoon
		end
			
			
	end
end


function Buttons:Buy1(wtycoon)
	
	for _,Button in pairs(CollectionService:GetTagged("Button")) do
		
		Button.Head.Touched:Connect(function(player)
			
			if player.Parent:FindFirstChild("Humanoid") then
				local Player = game.Players:GetPlayerFromCharacter(player.Parent)
				local Cash = Player.leaderstats.Cash.Value
			
			local NextId = Button:GetAttribute("NextId")
				
				print(Cash)
			
			for _,Button2 in pairs(CollectionService:GetTagged("Button")) do
				
				local CurrentId = Button2:GetAttribute("CurrentId")
					local Cost = Button2:GetAttribute("Cost")
					print(Cost) print(CurrentId) print(NextId)
					if NextId == CurrentId and Cash > Cost then
						print(NextId)
						local CButton = Button2:Clone()
						Cash -= Cost
						CButton.Parent = wtycoon
						Button:SetAttribute("Used", true)
						
				elseif Cash < Cost then print("Not Enough Money")		
				end
				
			end			
					
				end
				
			end)
			
			
			
		end
		
	end
	


function Buttons:Sell()
	
	for _, Button in pairs (CollectionService:GetTagged("Button")) do
		
		if Button:GetAttribute("Used") == true
			then  Button:Destroy()
		end
	end
end

return Buttons

Maybe it does run? Put a print statement at the end of your scripts to see if they are reached. Otherwise, use breakpoints to see exactly what your script is doing.

I put a print on the very end, I will try put some more to see at what line the script is falling and what is a breakpoint?

I made a test and the script only runs until between the first and the second end