Cant assign text to textLabel

the code that creates the text label is

function module.createTextLabel(text,parent)
	local text = assets.Text:Clone()
	text.Text = text
	text.Parent = parent
	return text
end
local gui = players.LocalPlayer.PlayerGui.ScreenGui
button.MouseButton1Down:Connect(function() 
	local frame = uiLib.createFrame("Test",gui.BkgFrame)
	local text = uiLib.createTextLabel("This is an example of a custom frame",frame)
end)

not sure why it wont work

  21:13:02.983  Unable to assign property Text. string expected, got Instance  -  Client - UIModule:26
  21:13:02.985  Stack Begin  -  Studio
  21:13:02.985  Script 'ReplicatedStorage.Modules.UIModule', Line 26 - function createTextLabel  -  Studio - UIModule:26
  21:13:02.986  Script 'Players.Techononux3.PlayerGui.ScreenGui.BkgFrame.MainFrame.TextButton.LocalScript', Line 14  -  Studio - LocalScript:14
  21:13:02.986  Stack End  -  Studio

You are cloning the label and setting its text to itself, it means that its a not a string(text)

Its like “Label.Text = Part”, it wont work

1 Like

In your createTextLabel function, there is a parameter named text and a variable named text. The error could be happening because the script is getting confused on which one to set as the Text (instance)'s text. So simply change the variable/parameter names to differ from each other.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.