Surface gui problem

Hello, I have a problem of my script at the line “for i, Frame in pairs(LeaderboardPart.SurfaceGui.Stat:GetChildren()) do” and got the error:"SurfaceGui is not a valid member of SurfaceGui “Workspace.LeaderboardPart.SurfaceGui”.

I did some debugging and that it prints the uilist,the script itself,and the frame that contains the text.But i still dont know how to fix it.

while true do
	
	for i, Frame in pairs(LeaderboardPart.SurfaceGui.Stat:GetChildren()) do
		print(i, Frame)
		if Frame.Name ~= "Template" and Frame:IsA("Frame") then
			Frame:Destroy()
		end
	end
	RefreshLeaderboard()
	wait(refreshtime)
end

you set your surface GUI to “LeaderboardPart”
banner

Hi! As @creepkiller1234 mentioned I think your hierarchy might be a little off. Also, make sure to use ipairs for indexed tables!

I think my hierarchy is just fine,or is there a problem with it?
Code2

Hmmm, if I assume your script is the leaderboard script, have you tried to create a local script which is the direct child of SurfaceGui then do the following:

while true do

for i, Frame in ipairs(script.Parent:WaitForChild("Stat"):GetChildren()) do
		print(i, Frame)
		if Frame.Name ~= "Template" and Frame:IsA("Frame") then
			Frame:Destroy()
		end
	end
	RefreshLeaderboard()
	wait(refreshtime)
end

I hope this helps!

Nevermind i have figured it out. it turns out that i did not parent the template
Code5

Hi! I am glad you figured it out. A small suggestion, input the full script, as sometimes the errors can be from completely unrelated areas!

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