How to make a billboard gui disappear when a button is stepped on?
Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
Here is the purchase handler. This is a tycoon i am trying to make which is based off of ZTK but i want to have custom text instead of the ugly roblox default text.~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~ --[[
All configurations are located in the "Settings" Module script.
Please don't edit this script unless you know what you're doing.
--]]
local Objects = {}
local TeamColor = script.Parent.TeamColor.Value
local Settings = require(script.Parent.Parent.Parent.Settings)
local Money = script.Parent.CurrencyToCollect
local Debris = game:GetService('Debris')
local Stealing = Settings.StealSettings
local CanSteal = false -- don't change or else you won't be able to steal currency
001 | script.Parent.Essentials.Spawn.TeamColor = TeamColor |
002 | script.Parent.Essentials.Spawn.BrickColor = TeamColor |
004 | function Sound(part,id) |
005 | if part:FindFirstChild( 'Sound' ) then |
008 | local Sound = Instance.new( 'Sound' ,part) |
011 | delay(Sound.TimeLength, function () |
018 | for i,v in pairs (script.Parent.Essentials:GetChildren()) do |
019 | if v.Name = = "PartCollector" then |
020 | v.Touched:connect( function (Part) |
021 | if Part:FindFirstChild( 'Cash' ) then |
022 | Money.Value = Money.Value + Part.Cash.Value |
023 | Debris:AddItem(Part, 0.1 ) |
031 | script.Parent.Essentials.Giver.Touched:connect( function (hit) |
032 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
033 | if player ~ = nil then |
034 | if script.Parent.Owner.Value = = player then |
035 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
036 | if hit.Parent.Humanoid.Health > 0 then |
039 | script.Parent.Essentials.Giver.BrickColor = BrickColor.new( "Bright red" ) |
040 | local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
042 | Sound(script.Parent.Essentials, Settings.Sounds.Collect) |
043 | Stats.Value = Stats.Value + Money.Value |
046 | script.Parent.Essentials.Giver.BrickColor = BrickColor.new( "Sea green" ) |
052 | elseif Stealing.Stealing then |
053 | if CanSteal = = true then |
055 | delay(Stealing.PlayerProtection, function () |
058 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
059 | if hit.Parent.Humanoid.Health > 0 then |
060 | local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
062 | local Difference = math.floor(Money.Value * Stealing.StealPrecent) |
063 | Sound(script.Parent.Essentials, Settings.Sounds.Collect) |
064 | Stats.Value = Stats.Value + Difference |
065 | Money.Value = Money.Value - Difference |
070 | Sound(script.Parent.Essentials, Settings.Sounds.Error) |
076 | script.Parent:WaitForChild( "Buttons" ) |
077 | for i,v in pairs (script.Parent.Buttons:GetChildren()) do |
079 | if v:FindFirstChild( "Head" ) then |
081 | local ThingMade = script.Parent.Purchases:WaitForChild(v.Object.Value) |
082 | if ThingMade ~ = nil then |
083 | Objects [ ThingMade.Name ] = ThingMade:Clone() |
087 | error ( 'Object missing for button: ' ..v.Name.. ', button has been removed' ) |
088 | v.Head.CanCollide = false |
089 | v.Head.Transparency = 1 |
090 | v.Head.BillboardGui.Enabled = false |
093 | if v:FindFirstChild( "Dependency" ) then |
094 | v.Head.CanCollide = false |
095 | v.Head.Transparency = 1 |
096 | v.Head.BillboardGui.Enabled = false |
097 | coroutine.resume(coroutine.create( function () |
098 | if script.Parent.PurchasedObjects:WaitForChild(v.Dependency.Value) then |
099 | if Settings [ 'ButtonsFadeIn' ] then |
101 | wait(Settings [ 'FadeInTime' ] / 20 ) |
102 | v.Head.Transparency = v.Head.Transparency - 0.05 |
105 | v.Head.CanCollide = true |
106 | v.Head.Transparency = 0 |
107 | v.Head.BillboardGui.Enabled = true |
112 | v.Head.Touched:connect( function (hit) |
113 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
114 | if v.Head.CanCollide = = true then |
115 | if player ~ = nil then |
116 | if script.Parent.Owner.Value = = player then |
117 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
118 | if hit.Parent.Humanoid.Health > 0 then |
119 | local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
120 | if PlayerStats ~ = nil then |
121 | if (v:FindFirstChild( 'Gamepass' )) and (v.Gamepass.Value > = 1 ) then |
122 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(player,v.Gamepass.Value) then |
123 | Purchase( { [ 1 ] = v.Price.Value, [ 2 ] = v, [ 3 ] = PlayerStats } ) |
125 | game:GetService( 'MarketplaceService' ):PromptPurchase(player,v.Gamepass.Value) |
127 | elseif (v:FindFirstChild( 'DevProduct' )) and (v.DevProduct.Value > = 1 ) then |
128 | game:GetService( 'MarketplaceService' ):PromptProductPurchase(player,v.DevProduct.Value) |
129 | elseif PlayerStats.Value > = v.Price.Value then |
130 | Purchase( { [ 1 ] = v.Price.Value, [ 2 ] = v, [ 3 ] = PlayerStats } ) |
131 | Sound(v, Settings.Sounds.Purchase) |
133 | Sound(v, Settings.Sounds.ErrorBuy) |
146 | function Purchase(tbl) |
150 | stats.Value = stats.Value - cost |
151 | Objects [ item.Object.Value ] .Parent = script.Parent.PurchasedObjects |
152 | if Settings [ 'ButtonsFadeOut' ] then |
153 | item.Head.CanCollide = false |
154 | coroutine.resume(coroutine.create( function () |
156 | wait(Settings [ 'FadeOutTime' ] / 20 ) |
157 | item.Head.Transparency = item.Head.Transparency + 0.05 |
161 | item.Head.CanCollide = false |
162 | item.Head.Transparency = 1 |
163 | item.Head.BillboardGui.Enabled = false |
168 | local x = Instance.new( 'Model' ) |
169 | Instance.new( 'NumberValue' ,x).Value = tab [ 1 ] |
170 | x.Value.Name = "Cost" |
171 | Instance.new( 'ObjectValue' ,x).Value = tab [ 2 ] |
172 | x.Value.Name = "Button" |
173 | local Obj = Instance.new( 'ObjectValue' ,x) |
176 | x.Parent = script.Parent.BuyObject |
180 | script.Parent:WaitForChild( 'BuyObject' ).ChildAdded:connect( function (child) |
182 | tab [ 1 ] = child.Cost.Value |
183 | tab [ 2 ] = child.Button.Value |
184 | tab [ 3 ] = child.Stats.Value |