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

Why isn't text appearing in the textLabel?

Asked by 3 years ago

This script is supposed to make the text "I have to get out of here..." appear once the Frame is set to visible. It doesn't work. The Frame will appear but no text will.

if script.Parent.Frame.Visible == true then

    local textLabel = script.Parent.Frame.TextLabel_Roundify_12px.TextLabel

    local function typewrite(object,text)
    for i = 1, #text, 1 do
        object.Text = string.sub(text,1,i)
        wait(0.1)
    end
    end


    wait(.1)
    print("yes")
    typewrite(textLabel, "I have to get out of here...")
end

I happen to be in a tropical storm so any responses may be delayed.

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
3 years ago

The script runs as soon as you hit play, meaning that the script will stop because the Frame isn't visible at the time it ran (which is as soon as you play/run the game, scripts run very fast). You can use the Changed event to check if the frame becomes visible.

function Changed()
if script.Parent.Frame.Visible == true then

    local textLabel = script.Parent.Frame.TextLabel_Roundify_12px.TextLabel

    local function typewrite(object,text)
    for i = 1, #text, 1 do
        object.Text = string.sub(text,1,i)
        wait(0.1)
    end
    end


    wait(.1)
    print("yes")
    typewrite(textLabel, "I have to get out of here...")
end
end

script.Parent.Frame.Changed:Connect(Changed)

Hope this helps. Also, I believe the line with textLabel would cause an error.

0
Thank you. The script works as intended now. ImAwesome444445 13 — 3y
Ad

Answer this question