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

Is there anything similar to FindFirstChild that doesn't require a string?

Is there any other beside FindFirstChild that doesn't require a string? I need it because I want this script to work universally so I won't have to keep changing the Guis name.

Ok,so this is how the script works it finds the player distance if distance is less then 4 then it will clone the Gui into the Players Gui and then it will see if the player has the Gui by checking the Guis name,however if the the player already has a gui with the same name it won't work,is there another way to do it? The script is setup like this.

For example: Tag a object and make it find it first.

 Copy = Gui:Clone()--Tagged as Copy
                FoundCopy = Player.PlayerGui:FindFirstChild(Copy)
while wait() do
    for _,Player in pairs( game.Players:GetChildren() ) do
        -------------------------------------------------------
        local Part = script.Parent
        local Character = Player.Character
        local Distance = (Character.Torso.Position - Part.Position).magnitude
        ------------------------------------------------------- 
        print(Distance)
        if Distance < 4 then
            for _,Gui in pairs (Part.GuiFolder:GetChildren())do
                Copy = Gui:Clone()
                FoundCopy = Player.PlayerGui:FindFirstChild(Copy.Name)---Finds the Gui named "ScreenGui"
                if not FoundCopy then---Checks if the player doesn't have the gui
                    Copy.Parent = Player.PlayerGui
                end
            end
        end
    end
end

1 answer

✓ Accepted answer

Please upvote my rep and mark this as the correct answer if this solved/answered your question :)

To find gui in backpack:

function getGui()
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("Backpack") then
			for __, gui in pairs(v:GetChildren()) do
				if v:IsA("ScreenGui") then return v end			
			end
		end
	end
end

With multiple guis:

Add a model to the gui you want to locate and then name it locateThis

function getGui()
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("Backpack") then
			for __, gui in pairs(v:GetChildren()) do
				if v:IsA("ScreenGui") then
					if gui:findFirstChild("locateThis") then
						return v
					end
				end			
			end
		end
	end
end

10 comments

0

Agreed I was going to ask that. Here have some comment time

0

How about now?

0

What part are you talking about, finding the backpack in it incase you change the name, or the gui in the backpack, or both, or if the player has the gui already?

0

Finding it in the backpack just in case I change the name

0

Oh... updating post.

0

No. To fix this you would need a BoolValue or something to verify that its that screengui.

0

Will it work if It has a lot of Guis in the players backpack,and if so how would I check if the player has the specific gui so it will stop cloning?

0

and If you can,can you add to the script?

0

Yes.

0

Oh and if I wanted to remove that specific Gui how would I remove it?Oh, and sorry for all these requests.

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