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

No errors yet my local script will not do its job, what's wrong?

Asked by 2 years ago
local text = script.Parent:WaitForChild("NotAdmin")

local tr = text.TextTransparency

local function w()
    wait(0.05)
end


print("Enabled text")
tr = 0.9
w()
tr = 0.8
w()
tr = 0.7
w()
tr = 0.6
w()
tr = 0.5
w()
tr = 0.4
w()
tr = 0.3
w()
tr = 0.2
w()
tr = 0.1
w()
tr = 0
print("Waiting for 4 seconds")
wait(4)
tr = 0.1
w()
tr = 0.2
w()
tr = 0.3
w()
tr = 0.4
w()
tr = 0.5
w()
tr = 0.6
w()
tr = 0.7
w()
tr = 0.8
w()
tr = 0.9
w()
tr = 1
print("Disabled text")
wait(5)
script.Disabled = true

It prints as expected but does not actually change the "TextTransparency". Please help ;)

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

First of all, this code is just too long, we can make this so much shorter using TweenService or a for loop.

For this to work, just insert a LocalScript into the TextLabel.

Tweening

local TweenService = game:GetService("TweenService") -- retrieving TweenService
local tweenInfo = TweenInfo.new(
    5, -- The period of time it takes to tween
    Enum.EasingStyle.Linear, -- This is an easing style
    Enum.EasingDirection.Out, -- This is an easing direction
    -1, -- This is the number of times the tween will run. Setting this to -1 means it will run indefinitely
    true, -- This means whether it will reverse the tween
    0) -- This is a delay before the tween starts in seconds
local properties = {TextTransparency = 1} -- [[The property we're trying to change. Also, make sure to get the spelling of the property correct cause it will result in an error]]

local TextLabel = script.Parent -- This is just the reference for our TextLabel

TweenService:Create(TextLabel, tweenInfo, properties):Play() --[[ This creates our tween and instantly plays if you don't want the tween to instantly start playing just create a variable for it and play it]]

For loop

local TextLabel = script.Parent -- Referencing the Text label

for count1 = 0, 1 ,0.1 do

    TextLabel.TextTransparency = count1
    wait(0.05) -- the wait between each iteration
end

for count2 = 1, 0, -0.1 do

    TextLabel.TextTransparency = count2
    wait(0.05) -- the wait between each iteration
end

--[[
In the for loop, we're setting the variable to the following numbers.
The first number represents the starting position,
the second number represents the end position and
the third number represents the increment.
For this case, we're setting the TextTransparency to the control variable.
If the increment value is not defined then by default it will be 1
]]

Any questions? Just reply to my answer.

0
Thanks a ton! I used the for-loop method and edited the for-loop integers to fix one small issue but it now works. PaleNoobs 37 — 2y
Ad

Answer this question