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 -------------------------
What about using one script that handles all the buttons. Create all your buttons and have it clone and destroy the buttons you don't want to show yet.
When a button is pressed and the player has enough money the clone you created of the next button would be re-added to the model/workspace.
assuming that all your buttons are in a model and the script is in the model
local B = script.Parent.ButtonB:clone() script.Parent.ButtonB:Destroy()
For example
when ButtonB is touched (This is the function) if the player has enough money ( your if statement) your code (whatever you want you code to do when the player has enough money) set clone B's parent to model (Now re-add button b to model) destroy ButtonA (remove button a from model) (else statement for when player doesn't have enough money)
Hope this helps.