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

How am i supposed to do this?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Ok, I'm trying to make a SurfaceGui Textlabel that is empty but when you click it it has some text...? A script I tried was something like ~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~OnMouseClicked Part.SurfaceGui.TextLabel.Text = Chairman wait(10) Destroy() end

0
Sorry im new EpicalAgent56 5 — 9y

2 answers

Log in to vote
2
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, TextLabels don't have a click event, but TextButtons do! You just need some quotes on your string, fix your hierarchy and you're good!

script.Parent.MouseButton1Down:connect(function()
    script.Parent.Text = "Chairman"
    wait(10)
    -- Not sure if you wanted to destroy the part, SurfaceGui, or the message.
    --[[ If you want to destroy the part:
        script.Parent.Parent.Parent:Destroy()

        If you want to destroy the GUI:
        script.Parent.Parent:Destroy()

        If you want to delete the TextButton
        script.Parent:Destroy()

        If you want to clear it:
        script.Parent.Text = ""
    --]]
end)

So here's the hierarchy I set this up for (The location, or directory):

Workspace>Part>SurfaceGui>TextButton>Script

Ad
Log in to vote
0
Answered by
AxeOfMen 434 Moderation Voter
9 years ago

A TextLabel does not respond to clicks. You need to use a TextButton instead.

local TextButton = Part.SurfaceGui.TextButton
TextButton.MouseButton1Click:connect(function()
    TextButton.Text = "Chairman"
    wait(10)
    TextButton:Destroy()
end)

I'm not sure what element you were wanting to destroy in the code sample you provided. Mine destroys the TextButton

0
you know what i remember. i dont want to destroy it, i want it to disappear then you have to click again. but i know what to do. i really like this site:) EpicalAgent56 5 — 9y

Answer this question