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
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