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

How can I subtract words from a TextLabel ?

Asked by 5 years ago
Edited 5 years ago

I am trying to make an blink meter which decreases over time. The thing here is that I am using a text label for that, so it means I'm using strings. !What it looks like in-game!What it looks like in-studio For that, i'm using the current script below :

repeat wait() until script.Parent.Parent:IsA("PlayerGui")
repeat wait() until script.Parent.Parent.MainScreen.Enabled==false or script.Parent.Parent.MainScreen==nil
local frame = script.Parent.Visual
local txt = frame.BlinkMeter
local coverup = frame.BlinkCoverUp
local FirstTime = true -- Prevents See173 from playing more than one time
local Test = true -- Prevents See173 from playing upon enter. The script should be disabled by default.

if FirstTime and not Test then
script.Parent.See173:Play()
FirstTime = false
end
-- V  This part seems to malfunction  V --
while wait() do
repeat
for i=-1,#txt.Text do
txt.Text = string.sub(txt.Text,-1,i)
wait(0.75)
end
until txt.Text=="" or txt.Text==nil
for i=-.05,coverup.BackgroundTransparency do
coverup.BackgroundTransparency=coverup.BackgroundTransparency-.05
wait(0.06)
end
for i=0.01,1 do
coverup.BackgroundTransparency=coverup.BackgroundTransparency+.05
wait(0.06)
end
txt.Text="? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "
end
-- End of malfunctioning part --

? is an special character. However, whenever I go in-game to test, the blink meter is already empty. And at an interval it fills back to default for a split second, the BlinkCoverUp (blink effect) is shown and then everything repeats. I'm probably doing something wrong in the malfunctioning part.

I was instead expecting the blink meter to remove "? every 0.75 seconds, when it's fully empty, the BlinkCoverUp shows up and dissappears, then the blink meter goes back to normal, and the cycle begins a new.

What can I do instead ?

Notes : FilteringEnabled set to true, script (and objects) in StarterGui.

Answer this question