I made a script with a SurfaceGui in it. The script is located in a Model with tons of Parts all named Screen.
What I want to do is for the script to replicate the SurfaceGui into all the Parts at once, however the problem is that it only replicates once, and in only one particular Screen instead. Do I need to add a while loop or something?
--
rep = script.SurfaceGui:Clone()
for i,v in pairs(game.Workspace.InformationScreens:GetChildren()) do if v.Name == "Screen" then rep.Parent = v end end
You never cloned the gui inside of the loop. So here you go:
for i,v in pairs(game.Workspace.InformationScreens:GetChildren()) do if v.Name == "Screen" then rep = script.SurfaceGui:Clone() rep.Parent = v end end
Your :GetChildren() script probably did not use a loop what :GetChildren() does is get all the children but, it doesn't allow you to access each of them separately to do that you would use a for loop something like this...
local children = script.Parent:GetChildren() for i = 1, #children, do wait() local gui = script.SurfaceGui:clone() if children[i].Name == Screen then gui.Parent = children[i] end end
This will go through every single object inside of the model and it will clone the gui every time the for loop runs and parent it to whatever 'i' is and since it's a for loop it's changing value every time it loops..