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

Why doesn't the text transparency of my textbox change back to 0 after tween to 1?

Asked by 4 years ago

I made a remote event which fully functions as it's meant to but every time it happens It doesn't change the text transparency back to 0 how it should do. Here is my script:

local RS = game:GetService("ReplicatedStorage")
local eventsFolder = RS:WaitForChild("RemoteEvents")
local xpEvent = eventsFolder:WaitForChild("XpNotify")

local notifier = script.Parent

local TweenService = game:GetService("TweenService")

--//Tweening Information
local tInfo = TweenInfo.new(1)
local goal = {}
goal.TextTransparency = 1
local tween = TweenService:Create(notifier, tInfo, goal)
--//Script
xpEvent.OnClientEvent:Connect(function(xpAmount)
    print(xpAmount.."xp gained by ".. game.Players.LocalPlayer.Name) --//Prints
    notifier.Text = tostring(xpAmount)
    notifier:TweenPosition(UDim2.new(1, 0,-0.829, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad, 0.5)
    wait(1)
    tween:Play()
    notifier.Position = UDim2.new(0.25, 0,-0.829, 0)
    repeat
    notifier.TextTransparency = 0 --//Fsr doesn't change it back.
    until notifier.TextTransparency
    print("XP transition DONE!!") --//Prints
end)

Thank you for your time and I hope you have an answer to this question. Any help is appreciated.

0
I'm not the best at scripting I'm new here, but try using breakpoints to figure out the line that it stops at ArCeMo6 -1 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

Keep in mind, Tweens do not yield the thread until they are done. This means that if you want to wait for the tween to complete, you have to manually add a wait. Since your tween runs for 1 second, you can fix this with a simple

tween:Play()
wait(1)

If this answer was helpful, please don't forget to mark as solution, thx c;

Ad
Log in to vote
0
Answered by 4 years ago

Keep in mind, Tweens do not yield the thread until they are done. This means that if you want to wait for the tween to complete, you have to manually add a wait. Since your tween runs for 1 second, you can fix this with a simple

tween:Play()
wait(1)

If this answer was helpful, please don't forget to mark as solution, thx c;

Answer this question