So basically I'm making a tycoon to test out my scripting abilities. The way it's laid out is there is a model called "Tycoon" and it has 3 main children models: "Buttons", "Products", and "Drops". Inside The drops group is irrelevant because its just where i place the droppers products when they get cloned into the workspace and disappear after a few seconds. Within the products group are models that I made for the buttons to buy. Now bear with me because it gets confusing here. Each button has an IntValue, StringValue, and ObjectValue. The IntValue is the price, StringValue is what appears above the button in-game, and I set the object value to what i want to appear in the game. Here is the script of a button:
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
Debounce = false
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 and Debounce == false then --Checking if the button has been pressed before.
Debounce = true
plr.leaderstats.Money.Value=plr.leaderstats.Money.Value-price
product.Parent=script.Parent.Parent.Parent
for i = 1, 10 do
script.Parent.Head.Transparency = script.Parent.Head.Transparency + .1
wait(.1)
end
script.Parent:remove()
end
end
end)
It works fine, no need to check over it, it's just there for reference. The REAL problem is I want certain buttons to not be available until another button is pressed. I've tried adding a second Object Value to a button (we'll call it button1) and have that set to another button (button2). In-game one of two things will happen. Either button 2 is already there when the server starts up AND it's product is already there without it being bought, OR when i press button1, button2 appears (as well as the normal product) but button2's object value is gone. Is there any easier way of doing this because it seems to me like I'm over complicating things. Sorry for the abnormally long post but I didn't want this to sound like a request and tell you guys what I've tried. Thanks for the help
