How to make something depend on another

I’m currently using a tycoon kit, but instead of using Humanoids to display what you’ll buy when you step on it, I use BillboardUI’s, so it looks like this.

image

When you actually play the game, the buttons don’t appear because you haven’t started the tycoon or haven’t progressed enough, etc, which is intentional. Just when the button’s don’t appear, or aka being transparent, the BillboardUI’s are still there giving you this result:

image

So my question is, how would I go about making a script that checks if the part is transparent or not, so that the BillboardUI would follow it’s lead, something like this

if script.Parent.Transparency == 1 then
	
	script.Parent.BillboardGui.Enabled = false
	
elseif script.Parent.Transparency == 0 then
	
	script.Parent.BillboardGui.Enabled = true

end

In other words, if the part is invisible then the BillboardUI wouldn’t be enabled, if the part is visible then the BillboardUI would be enabled, this is my setup.

image

“Head” being the part you step on to make the purchase, just like all tycoons. It used to have a Humanoid to display it’s use/name, so that’s why it’s named that way.

I couldn’t find help elsewhere and have tried everything, so help would be much appreciated! I’m not really trying to learn scripting but that’s all I know. Thanks!

2 Likes

Hey, there’s a few ways you can do this. Personally I would just check if the part is transparent or not every time there’s a change with the part, then enable/disable the GUI appropriately. I’ve left a basic example below.

Server Script:

local Part = script.Parent --The part
local UI = Part.BillboardGui --The billboard GUI


Part.Changed:Connect(function() --function
	if Part.Transparency == 0 then --If the transparency is 0 then the following will happen;
		UI.Enabled = true --This will make the billboard GUI visible
	else --If the transparency is not 0 then the following will happen;
		UI.Enabled = false --This will make the billboard GUI invisible
	end
end)

Hope this helped

2 Likes