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

The Button Disepars if i set transparency to 1 Help is appreciate :D ?

Asked by 3 years ago
local ButtonModel = script.Parent
local Object = ButtonModel.Object
local Cost = ButtonModel.Cost
local Dependency = ButtonModel.Dependency
local Button = ButtonModel.Head
local Text = Button.BillboardGui.TextLabel

Text.Text = Object.Value.Name.." - "..tostring(Cost.Value).."€"

if Dependency.Value == "None" then
    for i,v in pairs(Object.Value:GetChildren()) do
        if v:IsA("BasePart") then
            v.Transparency = 1
            v.CanCollide = false
        elseif v:IsA("TextLabel") then
            v.TextTransparency = 1      
        end
    end
else
    for i,v in pairs(ButtonModel:GetChildren()) do
        if v:IsA("BasePart") then
            v.Transparency = 1
            v.CanCollide = false
        elseif v:IsA("TextLabel") then
            v.TextTransparency = 1      
        end
    end
    for i,v in pairs(Object.Value:GetChildren()) do
        if v:IsA("BasePart") then
            v.Transparency = 1
            v.CanCollide = false
        elseif v:IsA("TextLabel") then
            v.TextTransparency = 1      
        end
    end
    if workspace.Buyed:FindFirstChild(Dependency.Value) then
        for i,v in pairs(ButtonModel:GetChildren()) do
            if v:IsA("BasePart") then
                v.Transparency = 0
                v.CanCollide = true
            elseif v:IsA("TextLabel") then
                v.TextTransparency = 0  
            end
        end
    end
end

Button.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
        local Cash = player.leaderstats.Euro
        if Cash.Value >= Cost.Value then
            Cash.Value = Cash.Value + Cost.Value
            for i,v in pairs(Object.Value:GetChildren()) do
                if v:IsA("BasePart") then
                    v.Transparency = 0
                    v.CanCollide = true
                elseif v:IsA("TextLabel") then
                    v.TextTransparency = 0      
                end
            end
            for i,v in pairs(ButtonModel:GetChildren()) do
                if v:IsA("BasePart") then
                    v.Transparency = 1
                    v.CanCollide = false
                elseif v:IsA("TextLabel") then
                    v.TextTransparency = 1      
                end
            end
            ButtonModel.Parent = workspace.Buyed
        end 
    end
end)

Don't be scared it's looking kinda hard but it's just simple script :D ok so If dependency is something other it's automaticly diseapers

1 answer

Log in to vote
0
Answered by
KingDomas 153
3 years ago
Edited 3 years ago

What's the issue here - like what is not working properly for you and you want to fix? I'm assuming you don't want the button to disappear? Transparency 1 = invisible, transparency 0 = visible, anything inbetween is transparent.

0
Thank you DefinitelyNotTronix 19 — 3y
0
Sorry i actually forget to anchor it so if i launch from rpg it will fling into void DefinitelyNotTronix 19 — 3y
Ad

Answer this question