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

I am trying to get an animated text gui to pop up when I click a brick. What am I doing wrong?

Asked by 4 years ago

It's basically someone talking when I click a bell. Picture of my code:https://ibb.co/QfZLJWn I have a click detector as the child of the brick I want to press, and this Script as the child of the TextLabel that will pop up. Anything I'm doing wrong? If you have any questions DM me at rebloom#9167. Thanks.

0
Id say using events and having them run would probably have it work how you want if I am understanding your question correctly. deth836231 142 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

From what I see, you don't assign the ClickDetector.MouseClick event to a function. The common way is to simply do

ClickDetector.MouseButton.MouseClick:Connect(function(playerWhoClicked)
    TextLabel = script.Parent
    local Text
    function soundEffect()
        local sound = Instance.new("Sound")
        sound.Parent = ClickDetector.Parent
        sound.Name = "Text Sound"
        sound.Volume = 1
        sound:Play()
        game.Debris:AddItem(sound, sound.TimeLength) --Deletes the sound after it stops playing
    end)
    function setText(word)
        Text = word
    end

    for i = 1, #Text do
        TextLabel.Text = string.sub(Text, 1, i)
        soundEffect()
        TextLabel.Color3 = Color3.fromRGB(0, 0, 0)
        if script.Parent.Parent.Parent.Enabled then
            local frame = script.Parent.Parent
            frame.Visible = true
            wait(0.04)
        end
    end
    wait(3)
    setText("Good Evening")
    wait(3)
    setText("What can I do for ye?")
    print("Done")
end)

If you're waiting for the event to happen, you'd write

ClickDetector.MouseClick:Wait()
--code here
0
Utter_Incompetence, still doesn't run. What am I doing wrong? https://ibb.co/PxfNHqB Cazacalism 17 — 4y
0
You gotta put the code inside the function! Utter_Incompetence 856 — 4y
Ad

Answer this question