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

is it possible to put a clicked event on a text label?

i was wundering if you could put a clicked event into a text label if its possible please tell me

3 comments

0

Nope. Only for textbuttons

0

TextButtons are practically the same as textlabels anyway. Just convert them.

0

convert 50 textlabels

1 answer

✓ Accepted answer

To convert textlabels to textbuttons, all you have to do is simply make a script for it in the command bar. It involves sending each component of the text label to the button. This script will change EVERY text label in a GUI. Keep in mind that if you want some text labels to STAY text labels, you will have to put their UNIQUE name into the table (if it isn't unique, you may have a label that needs to be converted to a textbutton be overlooked because of the name).

local tab = {DontRemoveMe = true,IMSTEVE = true} -- All textlabels with names of strings in the table can be ignored; alter this as you see fit.

function goThrough(obj)
	for _,v in pairs(obj:GetChildren()) do
		if v:IsA("TextLabel") and not tab[v.Name] then
			local txtB = Instance.new("TextButton")
			txtB.Active = v.Active
			txtB.BackgroundColor3 = v.BackgroundColor3
			txtB.BackgroundTransparency = v.BackgroundTransparency
			txtB.BorderColor3 = v.BorderColor3
			txtB.BorderSizePixel = v.BorderSizePixel
			txtB.Position = v.Position
			txtB.Size = v.Size
			txtB.Rotation = v.Rotation
			txtB.Selectable = v.Selectable
			txtB.SizeConstraint = v.SizeConstraint
			txtB.Visible = v.Visible
			txtB.ZIndex = v.ZIndex
			txtB.Font = v.Font
			txtB.FontSize = v.FontSize
			txtB.Text = v.Text
			txtB.TextColor3 = v.TextColor3
			txtB.TextStrokeColor3 = v.TextStrokeColor3
			txtB.TextStrokeTransparency = v.TextStrokeTransparency
			txtB.TextTransparency = v.TextTransparency
			txtB.TextWrapped = v.TextWrapped
			txtB.TextXAlignment = v.TextXAlignment
			txtB.TextYAlignment = v.TextYAlignment
			txtB.ClipsDescendants = v.ClipsDescendants
			txtB.Draggable = v.Draggable
			txt.Name = v.Name
			v:Destroy()
			txtB.Parent = obj
		end
		if #v:GetChildren()>0 then
			goThrough(v)
		end
	end
end

goThrough(game.StarterGui.GameGUI) -- Or whatever it's named.

2 comments

0

is it possible to go through this and convert names

0

Oh ok; I added a txtB.Name = v.Name to fix that.

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