Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How am i supposed to do this?

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 ~~~~~~~~~~~~~~~~~

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

1 comment

0

Sorry im new

2 answers

✓ Accepted answer

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

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

1 comment

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:)

This discussion is preserved as it was. New answers, comments, and votes are closed.