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

2 comments
Thank you
Sorry i actually forget to anchor it so if i launch from rpg it will fling into void