New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How to fix this fading text module?

Asked by
hokyboy 169
8 days ago
local module = {}
 function module.TextFade(plr)
    local CurrentTransparancy = 0
    local PlrUI = game.Players.LocalPlayer.PlayerGui.PlrUI
    for i = 1,100,.1
    do
        CurrentTransparancy = CurrentTransparancy + 1 
        PlrUI.Title.Transparancy = CurrentTransparancy
    end
end
return module

2 answers

Log in to vote
0
Answered by 8 days ago

Howdy!

You're rapidly increasing the transparency. Remember that a transparency of one is completely gone. Also, you've got a weird way of adding the transparency. Try what I have below.

local module = {}
function module.TextFade(plr)
    local CurrentTransparancy = 0
    local PlrUI = game.Players.LocalPlayer.PlayerGui.PlrUI
    while true do
            PlrUI.Title.Transparancy = PlrUI.Title.Transparancy + 0.1
        repeat until PlrUT.Title.Transparancy = 1
    end
end
return module

If this helped you out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I (or someone else) will help you out.

Be sure to check out the Roblox API Documentation as well for additional reference.

0
20:22:33.487 - ServerScriptService.Script.TextsModule:4: attempt to index nil with 'PlayerGui' hokyboy 169 — 8d
0
What is the name of the GUI you're trying to refer to? The error says that "PlrUI" doesn't exist, make sure the name is right. AwesomeHUnderwood 400 — 8d
0
Its not the GUI its refering to its says playergui hokyboy 169 — 8d
0
You need to use :WaitForChild("PlayerGui", 1), since the script is executing before the StarterGui is placed in the PlayerGui. Benbebop 571 — 8d
0
I read it wrong. I would try to use :WaitForChild() to get the PlayerGui because I think it's searching too early for it to appear. AwesomeHUnderwood 400 — 8d
Ad
Log in to vote
0
Answered by 8 days ago

Finding The Errors

local module = {}
 function module.TextFade(plr)
    local CurrentTransparancy = 0
    local PlrUI = game.Players.LocalPlayer.PlayerGui.PlrUI --// Error #1
    for i = 1,100,.1 --// Error #2
    do
        CurrentTransparancy = CurrentTransparancy + 1 --// Error #3
        PlrUI.Title.Transparancy = CurrentTransparancy --// Error #3
    end
end
return module

Error #1 - You already have plr passed through as an argument, and you cannot access LocalPlayer through a ModuleScript.

Error #2 - You are already making it invisible as it's starting at Transparency 1, and going to 100, by 0.1. You have to start it at 0 to make it visible, and the transparency only goes to 1, anything after that is the same as having it at 1.

Error #3 - You are increasing the transparency by 1, instead of using the variable i


Fixed Script

local fadeModule = {}

function module.FadeText(player)
    local playerGui = player:WaitForChild("PlayerGui")
    local UI = playerGui:WaitForChild("PlrUI")
    local title = UI:WaitForChild("Title")

    for i = 0,1,0.1 do
        title.Transparency = i
        game:GetService("RunService").Stepped:Wait() --// This will make it run smoother, better than using wait()
    end
end

return fadeModule

Hope this helped! Feel free to select this as an answer if this worked for you!

Answer this question