So I'm trying to make a simple tycoon as practice for scripting. What I'm basically trying to do is make a tycoon button that appears only when another tycoon button is pressed and disappears. When I test this script out, both buttons appear and work fine, but I only want one of them at first, and then the other after I press on that one. The line I added to try and check to see if something exists is line 1. Thank you for the help and sorry for the mess of the script
if script.Parent.Parent.Parent.Products:findFirstChild("Conveyor") then
repeat wait() until script.Parent.Product.Value~=nil
local product=script.Parent.Product.Value:clone()
script.Parent.Product.Value:remove()
local price=script.Parent.Price.Value
script.Parent.Name=script.Parent.ProductName.Value.." - "..price
if price==0 then
script.Parent.Name=script.Parent.ProductName.Value.." - Free!"
end
script.Parent.Head.Touched:connect(function(hit)
chr=hit.Parent
if chr:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(chr) then
plr=game.Players:GetPlayerFromCharacter(chr)
if plr.Name==script.Parent.Parent.Parent.OwnerName.Value and plr.leaderstats.Money.Value>=price then
plr.leaderstats.Money.Value=plr.leaderstats.Money.Value-price
product.Parent=script.Parent.Parent.Parent
script.Parent:remove()
end
end
end)
end
-------------------------
--Background info
--script.Parent is the button
--script.Parent.Parent is a model of all the buttons
--script.Parent.Parent.Parent is the whole tycoon model
--script.Parent.Parent.Parent.Products is a model of all the products that the buttons buy
-------------------------

3 comments
This sounds like it would work, but my tycoon isn't really normal and the buttons have different currencies to buy them with and sometimes they'll appear only if you complete a certain task, so it'd be much easier to insert a script into each of my buttons
Different currencies shouldn't be a problem. Just change your if statement to check the different currency and remove the different currency.
As for having buttons that are unlocked when you complete a certain task you could create a seperate model, called something like, TaskButtons, and then have the code handle all of that.