Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TextButtons won't go transparent with script?

Scripting novice here. Trying to make the screen go white with the color correction effect in lighting (since it looks nicer than a white frame turning opaque). Since this effect doesn't cover up the GUI, I wanted all the text on the screen to simply fade out when the button is clicked. This doesn't happen though, and only the screen goes white while the rest stays the same. Any idea how to fix it?

s = game:GetService("TeleportService")
id = 186379525

local cc = game.Lighting.ColorCorrection
local logo = game.StarterGui.logo.ImageLabel
local tut = game.StarterGui.tutorial.TUTORIAL
local change = game.StarterGui.changelog.Play
local cred = game.StarterGui.credits.Play
local play = game.StarterGui.play.Play

function onClicked()
	
	for i = 0.02,1.5,0.05 do
		cc.Brightness = i
		cred.TextTransparency = i
		tut.TextTransparency = i
		play.TextTransparency = i
		change.TextTransparency = i
		logo.ImageTransparency = i
		wait(0.01)
	end
	
s:Teleport(id)
end

script.Parent.MouseButton1Click:connect(onClicked)

1 answer

✓ Accepted answer

You should read this article to understand where UI is located in the game. You should be editing the LocalPlayer's PlayerGui, rather than the StarterGui.

This should be a LocalScript.

--WaitForChilds because things take time to load on the client
local s = game:GetService("TeleportService")
local id = 186379525
local cc = game.Lighting.ColorCorrection
local plr = game.Players.LocalPlayer --Define the Player
local ui = plr:WaitForChild("PlayerGui") --Search through PlayerGui
local logo = ui:WaitForChild("logo"):WaitForChild("ImageLabel")
local tut = ui:WaitForChild("tutorial"):WaitForChild("TUTORIAL")
local change = u:WaitForChild("changelog"):WaitForChild("Play")
local cred = ui:WaitForChild("credits"):WaitForChild("Play")
local play = ui:WaitForChild("play"):WaitForChild("Play")
local t = "TextTransparency" --Variable to keep the code concise.

function onClicked()
	for i = 0.02,1.5,0.05 do
		cc.Brightness = i
		cred[t],tut[t],play[t],chang[t]= i,i,i,i
		logo.ImageTransparency = i
		wait(0.01)
	end
	s:Teleport(id)
end

script.Parent.MouseButton1Click:Connect(onClicked) --'connect' is deprecated

This discussion is preserved as it was. New answers, comments, and votes are closed.