Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tycoon Script Does Not Show The Next Purchase Button. Why?

Asked by
LuaDLL 253 Moderation Voter
4 years ago

It will not set the transparency of the next purchase part to 0 and it keeps it invisible and I cant seem to figure out why.

Script:

local Tycoon = script.Parent.Parent
local Purchases = Tycoon:WaitForChild("Purchases")
local Buttons = Tycoon:WaitForChild("Buttons")
local Info = Tycoon:WaitForChild("TycoonInfo")
local CashToCollect = Info.CashToCollect
local Owner = Info.Owner

local Objects = {}

function ValidateHit(hit)
    local Char = hit.Parent
    if Char:IsA("Model") then
        local Player = game.Players:GetPlayerFromCharacter(Char)
        if Player then
            if Player.Name == Owner.Value.Name then
                return true
            end
        end
    end
    return false
end

for i,v in pairs(Buttons:GetChildren()) do
    local Object = Purchases:FindFirstChild(v.Object.Value)
    if Object then
        Objects[Object.Name] = Object:Clone()
        Object:Destroy()

        if v:FindFirstChild("Dependancy") then
            coroutine.resume(coroutine.create(function()
                local Button = v.Button
                Button.Transparency = 1
                Button.CanCollide = false
                if Purchases:WaitForChild(v.Dependancy.Value,90000) then
                    if Button then
                        Button.Transparency = 0
                        Button.CanCollide = true
                    else
                        Buttons[v.Name].Button.Transparency = 0
                        Buttons[v.Name].Button.CanCollide = true
                    end
                end
            end))
        else
            v.Button.Transparency = 0
        end
        local db = false
        v.Button.Touched:Connect(function(hit)
            local Valid = ValidateHit(hit)
            if Valid then
                if db == false then
                    db = true
                    if v.Button.Transparency == 0 then
                        Objects[v.Object.Value].Parent = Purchases
                        wait(.5)
                        v:Destroy()
                    end
                    db = false
                end
            end
        end)
    end
end

Answer this question