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

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)

0
Are all the prints printing through? Is this a localscript or a script? User#20279 0 — 6y
0
All the prints are printing. This is a script inside of the workspace. DaBrainlessOne 129 — 6y
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 — 6y
0
I literally have no idea how remove events work; I'll try to figure it out. Thanks for the advice DaBrainlessOne 129 — 6y

1 answer

Log in to vote
1
Answered by
ax_gold 360 Moderation Voter
6 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:

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)

Ad

Answer this question