Getting object name and turning it into a String

How would one get an object’s name and turn it into a string? Might sound kind of dumb, but I can’t figure it out for the life of me.

For example:

    local object = game.Workspace.Map.Game.Objects:FindFirstChild("candy");

    local name;

Is there a method that Roblox currently has, or a method that is already out there that can take the name of the object “candy” and initialize “name” with the words “candy,” like so?:

    local name = "candy";

The property object.Name gives you the string containing the name of the object.

print(object.Name) --candy
1 Like

Yep, as @NyrionDev said, object.Name gives a string, which would be the name.

1 Like

For your example you technically already have the name as a string as you’re passing it as an argument to “FindFirstChild()” to find an instance of some specified name. Regardless all you need to do is append .Name (the name property) at the end of an instance reference in order to get its name, so for your example that would be.

local object = game.Workspace.Map.Game.Objects:FindFirstChild("candy").Name