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

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

Asked by 7 years ago

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...

01local petrifier = script.Parent
02local badEndingClone = game.ServerStorage["Bad Ending."]:Clone()
03local texttransparency = badEndingClone.TextLabel.TextTransparency
04local textStrokeTransparency = badEndingClone.TextLabel.TextStrokeTransparency
05 
06local function steppedOn(part)
07    local parent = part.Parent
08    if game.Players:GetPlayerFromCharacter(parent) then
09        print(parent.Name .. " is being petrified!")
10        local player = game.Players:FindFirstChildOfClass("Player")
11                -- (there's coding here)
12        print("Bad ending thingy coming up")
13        badEndingClone.Parent = player.PlayerGui
14        for a = 1, 0, -0.1 do
15            texttransparency = (a)
View all 22 lines...
0
Are all the prints printing through? Is this a localscript or a script? User#20279 0 — 7y
0
All the prints are printing. This is a script inside of the workspace. DaBrainlessOne 129 — 7y
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. User#20279 0 — 7y
0
I literally have no idea how remove events work; I'll try to figure it out. Thanks for the advice DaBrainlessOne 129 — 7y

1 answer

Log in to vote
1
Answered by
ax_gold 360 Moderation Voter
7 years ago

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:

01local petrifier = script.Parent
02local badEndingClone = game.ServerStorage["Bad Ending."]:Clone()
03local text = badEndingClone.TextLabel
04 
05local function steppedOn(part)
06    local parent = part.Parent
07    if game.Players:GetPlayerFromCharacter(parent) then
08        print(parent.Name .. " is being petrified!")
09        local player = game.Players:FindFirstChildOfClass("Player")
10                -- (there's coding here)
11        print("Bad ending thingy coming up")
12        badEndingClone.Parent = player.PlayerGui
13        for a = 1, 0, -0.1 do
14            text.TextTransparency = (a)
15            print(text.TextTransparency)        
View all 21 lines...
Ad

Answer this question