How could i select an instance using a string?

I need a script to be able to find an instance only using a string inside a text label or value. How could i do this?
(If i need to, i can add value or other things but the main point)

Can you explain further? Then I could help you. :smile:

Im making a gui to fire control all the events from one gui, and i have a tab template thats cloned into the gui when the game starts. There’s only one script that know what each tab’s remote event is. I do have the events full name in each tab tho if that works. Is there a way to turn a string into a readable instance? Idk if that makes sense

Make a for loop and loop though each UI element, and check its name, then return that instance.

So your saying you have th full name of instances that you need but don’t know how to turn that into actually getting the instances?

use Instance:FindFirstChild(“string”).
looping is unnecessary

I think you could just do this; it’s very self explanatory

local instance  = workspace[textLabel.Text]

OR

local instance = workspace:WaitForChild(textLabel.Text)

The GUI was lookin events and remote events in replicated storage, some were parented in instances inside replicated storage, so im not sure if any of these would have worked. I did get it working and for anyone who might need it, here it is:

	EventOrigin=script.Parent.Parent.EventOrigin.Text
	print(EventOrigin)
	splitorigin=string.split(EventOrigin,".")
	for	i,v in pairs(splitorigin) do
		if i==1 then
			lastorigin=game.ReplicatedStorage
		else
			if lastorigin:FindFirstChild(v)~="ReplicatedStorage" then
				lastorigin=lastorigin:FindFirstChild(v)
			end
		end
	end
	AssignedEvent=lastorigin

I know it’s over complicated but it gets the job done :pray::pray::pray:

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