Billboard GUI Text Transparency change script

I want to add a billboard gui to my ore nodes in game. The ore nodes go transparent when they are empty, so they appear to be gone. Here is the script for that is working correctly.

local health = 200
local bool = true
local ongoing = true
local respawn = math.random(500,600)
local soundhit = script.Parent.soundhit

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('IsAPick') and ongoing == true then
		local status = hit.Parent:FindFirstChild('Type')
		if health > 0 then
			if status.Value == 'Common' then
				health = health - 20
				soundhit:Play()
				
			end
			
		elseif health <= 0 and bool == true then
			bool = false
		
			script.Parent.Transparency = 1
			script.Parent.CanCollide = false
			
			
			local wood = game.ReplicatedStorage.Ore4:Clone()
			local soundbreak = script.Parent.soundbreak
			wood.Parent = workspace
			wood:MoveTo(script.Parent.Position + Vector3.new(1,1,0))
			soundbreak:Play()
			ongoing = false
			health = 200 -- [ Put the original health here ] --
			wait(respawn)
			script.Parent.Transparency = 0
			script.Parent.CanCollide = true
			bool = true
			ongoing = true
			
			
		end
		
	end
end)

I tried adding in a line to make the billboardgui.texttransparency set from 1 to 0 but it breaks the entire script.

Anyone know why this second script does not work properly?

local health = 200
local bool = true
local ongoing = true
local respawn = math.random(300,360)
local soundhit = script.Parent.soundhit

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('IsAPick') and ongoing == true then
		local status = hit.Parent:FindFirstChild('Type')
		if health > 0 then
			if status.Value == 'Common' then
				health = health - 20
				soundhit:Play()
				
			end
			
		elseif health <= 0 and bool == true then
			bool = false
		
			script.Parent.Transparency = 1
			script.Parent.BillboardGui.TextTransparency = 1
			script.Parent.CanCollide = false
			
			
			local wood = game.ReplicatedStorage.Ore4:Clone()
			local soundbreak = script.Parent.soundbreak
			wood.Parent = workspace
			wood:MoveTo(script.Parent.Position + Vector3.new(1,1,0))
			soundbreak:Play()
			ongoing = false
			health = 200 -- [ Put the original health here ] --
			wait(respawn)
			script.Parent.Transparency = 0
			script.Parent.BillboardGui.TextTransparency = 0
			script.Parent.CanCollide = true
			bool = true
			ongoing = true
			
			
		end
		
	end
end)

BillboardGui instances don’t have a property named “TextTransparency”, stuff like “TextBox”,“TextLabel” instances do.

1 Like

As soon as I made this post I went back to attempt to fix it and saw I left out the TextLabel. lol

script.Parent.BillboardGui.TextLabel.TextTransparency = 1
script.Parent.BillboardGui.TextLabel.TextTransparency = 0

Thanks