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

Why can't I change the transparency of text using a script?

I'm trying to make text fade in, but the transparency of the text just refuses to change. I feel like I'm being a huge idiot here, but here's the script...

local petrifier = script.Parent
local badEndingClone = game.ServerStorage["Bad Ending."]:Clone()
local texttransparency = badEndingClone.TextLabel.TextTransparency
local textStrokeTransparency = badEndingClone.TextLabel.TextStrokeTransparency

local function steppedOn(part)
	local parent = part.Parent
	if game.Players:GetPlayerFromCharacter(parent) then
		print(parent.Name .. " is being petrified!")
		local player = game.Players:FindFirstChildOfClass("Player")
				-- (there's coding here)
		print("Bad ending thingy coming up")
		badEndingClone.Parent = player.PlayerGui
		for a = 1, 0, -0.1 do
			texttransparency = (a)
			print(texttransparency)			
			wait(1) 
		end
	end
end

petrifier.Touched:connect(steppedOn)

4 comments

0

Are all the prints printing through? Is this a localscript or a script?

0

All the prints are printing. This is a script inside of the workspace.

0

It could be because you can't change GUI stuff in a PlayerGui with a server script. Try using RemoteEvents and see if it works.

0

I literally have no idea how remove events work; I'll try to figure it out. Thanks for the advice

1 answer

The issue here is actually pretty simple. Let me try to explain:

on line 3, local texttransparency = badEndingClone.TextLabel.TextTransparency, you're changing a value named "texttransparency" to the current text's transparency. When you later type texttransparency = (a), You're not changing the text's transparency, your just changing a value with a similar name. You're doing the same thing with textstroketransparency. If you don't get what I'm saying, then try using this script instead:

local petrifier = script.Parent
local badEndingClone = game.ServerStorage["Bad Ending."]:Clone()
local text = badEndingClone.TextLabel

local function steppedOn(part)
    local parent = part.Parent
    if game.Players:GetPlayerFromCharacter(parent) then
        print(parent.Name .. " is being petrified!")
        local player = game.Players:FindFirstChildOfClass("Player")
                -- (there's coding here)
        print("Bad ending thingy coming up")
        badEndingClone.Parent = player.PlayerGui
        for a = 1, 0, -0.1 do
            text.TextTransparency = (a)
            print(text.TextTransparency)         
            wait(1) 
        end
    end
end

petrifier.Touched:connect(steppedOn)

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