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 3 years ago
01local text = script.Parent:WaitForChild("NotAdmin")
02 
03local tr = text.TextTransparency
04 
05local function w()
06    wait(0.05)
07end
08 
09 
10print("Enabled text")
11tr = 0.9
12w()
13tr = 0.8
14w()
15tr = 0.7
View all 53 lines...

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

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 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

01local TweenService = game:GetService("TweenService") -- retrieving TweenService
02local tweenInfo = TweenInfo.new(
03    5, -- The period of time it takes to tween
04    Enum.EasingStyle.Linear, -- This is an easing style
05    Enum.EasingDirection.Out, -- This is an easing direction
06    -1, -- This is the number of times the tween will run. Setting this to -1 means it will run indefinitely
07    true, -- This means whether it will reverse the tween
08    0) -- This is a delay before the tween starts in seconds
09local 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]]
10 
11local TextLabel = script.Parent -- This is just the reference for our TextLabel
12 
13TweenService: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

01local TextLabel = script.Parent -- Referencing the Text label
02 
03for count1 = 0, 1 ,0.1 do
04 
05    TextLabel.TextTransparency = count1
06    wait(0.05) -- the wait between each iteration
07end
08 
09for count2 = 1, 0, -0.1 do
10 
11    TextLabel.TextTransparency = count2
12    wait(0.05) -- the wait between each iteration
13end
14 
15--[[
View all 22 lines...

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 — 3y
Ad

Answer this question