Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

TextButtons won't go transparent with script?

Asked by
Stravan 18
6 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

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
Ad

Answer this question