Hey! You should be able to use model.Name, however I see another error in your code.
You refer to the text as the “Textlabel”, but that isn’t where the text is stored. you could try this:
local textLabel = script.Parent
local model = textLabel.Parent.Parent
textLabel.Text = model.Name
Hey, hope you’re well! I’m assuming you’re using a GUI to do this?
There’s a few errors in your script! The first one is your variables, as Blauwemelluk said, you should have local infront of them. The second one is that you have no function!
I’ve put together some code that changes the TextLabel whenever a TextButton is clicked!
local Text = script.Parent.TextLabel --// The Text property within a TextLabel
local Button = script.Parent.TextButton --// TextButton
local Model = workspace.Test --// The model that we're taking the name from.
Button.MouseButton1Click:Connect(function() --// Running the code below when the 'Button' is clicked.
Text.Text = Model.Name --// Setting the Text within the TextLabel to the name property of the Model.
end)
Every object in your game has properties, these properties are things that adjectives that describe or make your object what it is. For instance, a property of a part could be the ‘Transparency’ which determines how visible a part is.
In summary, when you look at your model for example you will see properties on the property window. (View > Properties) There you will see a bunch of properties including the ‘Name’ property.