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

How come a textlabel's text won't update? (Tried with printing)

Asked by 7 years ago

Here's my script;

local Clicker = script.Parent:WaitForChild("ClickDetector")
local QuestionMarkString1 = game.ReplicatedStorage:WaitForChild("TextStringValues").QuestionMarkClickGiver.QuestionMarkString1.Value
local QuestionMarkString1Length = string.len(QuestionMarkString1)
local ChatGui = game.ReplicatedStorage:WaitForChild("ScreenGuis").ChatGui
local ChatBubble = ChatGui:WaitForChild("ChatBubble")
local YesNoGui = game.ReplicatedStorage:WaitForChild("ScreenGuis").YesNoGui
local YesButton = YesNoGui:WaitForChild("YesButton")
local NoButton = YesNoGui:WaitForChild("NoButton")
local ChatGuiCloned = false
local YesNoGuiCloned = false

Clicker.MouseClick:connect(function(Clicked)
    if not ChatGuiCloned then
        local CloneChatGui = ChatGui:Clone()
        CloneChatGui.Parent = Clicked.PlayerGui
        ChatGuiCloned = true
        print("ChatGui has been Cloned, ChatGuiCloned has been set to true")
        if not YesNoGuiCloned then
            local CloneYesNoGui = YesNoGui:Clone()
            CloneYesNoGui.Parent = Clicked.PlayerGui
            YesNoGuiCloned = true
            print("YesNoGui has been Cloned, YesNoGuiCloned has been set to true")
            for i = 1,QuestionMarkString1Length do
                wait()
                ChatBubble.Text = string.sub(QuestionMarkString1, 1, i)
            end
        end
    end
end)

Dunno why it won't work, no errors a script inside a click detector

1 answer

Log in to vote
1
Answered by 7 years ago
string.animate = function(input)
    local newText = ""
    local index = 1
    return function()
        if index<#input then
            newText = newText..string.sub(input,index,index)
            index = index + 1
            return newText
        end
    end
end

for text in string.animate("Epic!") do
    print(text)
    wait(0.1)
end
Ad

Answer this question