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

Tycoon Button not Buying Object?

Asked by 3 years ago

HEY, there, I am having a issue with my tycoon. There is Not any errors. Tycoon Main Script (game.Workspace.Tycoons.Red Team.Main) :

local TycoonInfo = script.Parent.TycoonInfo
local OwnerValue = TycoonInfo.Owner
local CashToColectValue = TycoonInfo.CashToCollect
local Buttons = script.Parent.Buttons
local Purchases = script.Parent.Purchases
local Purchased = script.Parent.Purchased
local Objects = {}

--Start of Functions


function DoDevProductPurchase()

end 

function ValidDateHitbyowner(Hit)
    if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
        if Player and Player == OwnerValue.Value then
            return true
        end
        return false
    end
end

-- End Of Functions
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("Dependency") then
            coroutine.resume(coroutine.create(function()
                v.Button.Transparency = 1
                v.Button.CanCollide = false
                if Purchased:WaitForChild(v.Dependency.Value, 90000) then
                    v.Button.Transparency = 0
                    v.Button.CanCollide = false 
                end
            end))
        end
        local DB = false
        v.Button.Touched:Connect(function(Hit)
            if DB == false then
                DB = true
                if v.Button.Transparency == 0 then
                    if ValidDateHitbyowner(Hit) then
                        local MoneyValue = game.ServerStorage.PlayerMoney:FindFirstChild(OwnerValue.Value.Name)
                        if MoneyValue then
                            if MoneyValue.Value >= v.Price.Value then
                                MoneyValue.Value = MoneyValue.Value - v.Price.Value
                                Objects[v.Object.Value].Parent = Purchased
                                v:Destroy()
                            end
                        end
                    end 
                end
            end
        end)
    end
end

Answer this question