SurfaceGUI Problem

I dont know what to do anymore…

It is recommended that you do. I am explaining everything quite clearly here. If you’re here for help then you need to also need to understand stuff to help yourself.

Use this instead of the part where I did local UpperTorso = Character....

local UpperTorso = Character:WaitForChild("UpperTorso")
print(UpperTorso:GetChildren())
local Gui = UpperTorso:WaitForChild("NumberBack")

This is the code:

local Game,Workspace,Script = game,workspace,script
local RunService = Game:GetService("RunService")
local Camera = Workspace.CurrentCamera

local Character = Script.Parent
local Head = Character:WaitForChild("Head")
local UpperTorso = Character:WaitForChild("UpperTorso")
print(UpperTorso:GetChildren())
local Gui = UpperTorso:WaitForChild("NumberBack")

local function ToggleState()
	if (Camera.CFrame.Position - Head.Position).Magnitude < 1 then
		Gui.Enabled = false
	else
		Gui.Enabled = true
	end
end

RunService.RenderStepped:Connect(ToggleState)

Yet I’m still getting the 14:42:43.709 Infinite yield possible on 'Workspace.yHaruRBLX.UpperTorso:WaitForChild("NumberBack")' error.

I’m not sure if the code is correct or there are still some mistakes.

harmless, not useless. not to be picky but it meant different things

local Gui = UpperTorso:WaitForChild("NumberBack")
print(Gui) 
-- if it does NOT print the name, then there is actual problem in the hierarchy or name etc you need to further solve

-- if it print out the 'NumberBack', then it can still successfully get this gui
-- like i said, it is just because the stuffs need more time to load, the 'WaitForChild' has a few second period then it will complain, but is harmless
-- you can suppress the warning by a while loop wait
while not UpperTorso:FindFirstChild("NumberBack") do task.wait() end
local Gui = UpperTorso.NumberBack

I want you to reply with what it prints. Does it print something like: > {...}? If so, press the arrow and then send a screenshot here.

Your reply was indicating that it’s useless, or maybe it’s just me.
I am sure that, that error occurs when WaitForChild fails and if it fails the rest of the code fails to executes so the print you are using won’t actually even work.

i did tell you it print out β€˜NumberBack’
if you print an instance it print the name of it. not a β€˜table’

the OP has no problem with getting the UpperTorso,
because if it has problem, we should have got the β€˜nil’ related error instead of a β€˜WaitForChild’ error

so the problem whether the β€˜WaitForChild’ error is an actual one or a harmless one, we attempt to print the Gui
if it can print, the code did go through, it can find the Gui, the warning is harmless
if it cannot print, the code cannot go through, it cannot find the Gui, the warning is actual deal

It doesn’t seem to print anything, I don’t know how else i should fix it.
If this would help:
In ReplicatedStorage, I have Folder called β€œClothes” Inside the β€œClothes” Folder, There is a Folder called β€œPlayer”
Inside the Folder is this stuff:
{DA23CB1F-0AF8-46B3-BAFF-DC8DCACD9923}
I have a script, Whenever the player joins, Their clothes will be removed and the Clothes in the ReplicatedStorage will be duplicated, and the copy is parented onto the player. And the SurfaceGui is also cloned and Parented to the player’s UpperTorso.

I am using UpperTorso:GetChildren() which would just tell us if NumberBack actually exists within UpperTorso.

I do know that, I am not pointing my finger on it as well.
And, I am not going to argue with you here as our goal is to just help out the OP here. So back on the topic.

Do this:

local Game,Workspace,Script = game,workspace,script
local RunService = Game:GetService("RunService")
local Camera = Workspace.CurrentCamera

local Character = Script.Parent
local Head = Character:WaitForChild("Head")
local UpperTorso = Character:WaitForChild("UpperTorso")
repeat task.wait() until UpperTorso:FindFirstChild("NumberBack")
local Gui = UpperTorso.NumberBack

local function ToggleState()
	if (Camera.CFrame.Position - Head.Position).Magnitude < 1 then
		Gui.Enabled = false
	else
		Gui.Enabled = true
	end
end

RunService.RenderStepped:Connect(ToggleState)

This time, Nothing prints, No Error. However it still doesn’t work.

This means that for some reason NumberBack is not at ALL appearing in your game. This could be caused by your other script adding NumberBack.

The NumberBack does appear in the game though.

i think we were just having a miscommunication. all good :handshake:

err, strange. from the look of you script, it should have worked

Perhaps, try doing:

local Character = script.Parent
print(Character:GetDescendants())

A bit unexpected, I know.

What I want you to do is copy the entire output and paste it here. Can you do that?

Yes, I apologize for any inconvenience from my side.

That’s what I’m confused about. It should just work. I suspect that it’s wrong variables or something done wrong on the OP’s side.

My output is a mess because it contains messages from several plugins that are not releated to this situation.

…then can you please consider sending the output text related to the situation?

I ask you once more to cooperate with us here and to help us solve your issue. If you keep on asking or providing unnecessary responses then I am sorry to say that we are going no where with this.

1 Like
  15:23:23.175   {
                    [1] = Pants,
                    [2] = Shirt,
                    [3] = Body Colors,
                    [4] = Humanoid,
                    [5] = Animator,
                    [6] = BodyTypeScale,
                    [7] = BodyProportionScale,
                    [8] = BodyWidthScale,
                    [9] = BodyHeightScale,
                    [10] = BodyDepthScale,
                    [11] = HeadScale,
                    [12] = HumanoidDescription,
                    [13] = BodyPartDescription,
                    [14] = BodyPartDescription,
                    [15] = BodyPartDescription,
                    [16] = BodyPartDescription,
                    [17] = BodyPartDescription,
                    [18] = BodyPartDescription,
                    [19] = AccessoryDescription,
                    [20] = AccessoryDescription,
                    [21] = Status,
                    [22] = TEST,
                    [23] = Health,
                    [24] = Animate,
                    [25] = cheer,
                    [26] = CheerAnim,
                    [27] = climb,
                    [28] = ClimbAnim,
                    [29] = dance,
                    [30] = Animation1,
                    [31] = Weight,
                    [32] = Animation2,
                    [33] = Weight,
                    [34] = Animation3,
                    [35] = Weight,
                    [36] = dance2,
                    [37] = Animation1,
                    [38] = Weight,
                    [39] = Animation2,
                    [40] = Weight,
                    [41] = Animation3,
                    [42] = Weight,
                    [43] = dance3,
                    [44] = Animation1,
                    [45] = Weight,
                    [46] = Animation2,
                    [47] = Weight,
                    [48] = Animation3,
                    [49] = Weight,
                    [50] = fall,
                    [51] = FallAnim,
                    [52] = idle,
                    [53] = Animation1,
                    [54] = Weight,
                    [55] = Animation2,
                    [56] = Weight,
                    [57] = jump,
                    [58] = JumpAnim,
                    [59] = laugh,
                    [60] = LaughAnim,
                    [61] = point,
                    [62] = PointAnim,
                    [63] = sit,
                    [64] = SitAnim,
                    [65] = toollunge,
                    [66] = ToolLungeAnim,
                    [67] = toolnone,
                    [68] = ToolNoneAnim,
                    [69] = toolslash,
                    [70] = ToolSlashAnim,
                    [71] = wave,
                    [72] = WaveAnim,
                    [73] = ScaleDampeningPercent,
                    [74] = run,
                    [75] = RunAnim,
                    [76] = swim,
                    [77] = Swim,
                    [78] = swimidle,
                    [79] = SwimIdle,
                    [80] = walk,
                    [81] = WalkAnim,
                    [82] = PlayEmote,
                    [83] = mood,
                    [84] = Animation1,
                    [85] = Accessory (default),
                    [86] = Handle,
                    [87] = AvatarPartScaleType,
                    [88] = HairAttachment,
                    [89] = OriginalPosition,
                    [90] = OriginalSize,
                    [91] = AccessoryWeld,
                    [92] = Accessory,
                    [93] = Handle,
                    [94] = WrapLayer,
                    [95] = SurfaceAppearance,
                    [96] = FaceFront,
                    [97] = OriginalSize,
                    [98] = HumanoidRootPart,
                    [99] = RootRigAttachment,
                    [100] = OriginalPosition,
                    [101] = OriginalSize,
                    [102] = RootAttachment,
                    [103] = OriginalPosition,
                    [104] = Climbing,
                    [105] = Died,
                    [106] = GettingUp,
                    [107] = Swimming,
                    [108] = Jumping,
                    [109] = Landing,
                    [110] = Splash,
                    [111] = FreeFalling,
                    [112] = Running,
                    [113] = LowerTorso,
                    [114] = RootRigAttachment,
                    [115] = OriginalPosition,
                    [116] = LeftHipRigAttachment,
                    [117] = OriginalPosition,
                    [118] = WaistRigAttachment,
                    [119] = OriginalPosition,
                    [120] = RightHipRigAttachment,
                    [121] = OriginalPosition,
                    [122] = WaistFrontAttachment,
                    [123] = OriginalPosition,
                    [124] = WaistCenterAttachment,
                    [125] = OriginalPosition,
                    [126] = WaistBackAttachment,
                    [127] = OriginalPosition,
                    [128] = AvatarPartScaleType,
                    [129] = OriginalSize,
                    [130] = LowerTorso,
                    [131] = Root,
                    [132] = UpperTorso,
                    [133] = WaistRigAttachment,
                    [134] = OriginalPosition,
                    [135] = NeckRigAttachment,
                    [136] = OriginalPosition,
                    [137] = RightShoulderRigAttachment,
                    [138] = OriginalPosition,
                    [139] = LeftShoulderRigAttachment,
                    [140] = OriginalPosition,
                    [141] = RightCollarAttachment,
                    [142] = OriginalPosition,
                    [143] = LeftCollarAttachment,
                    [144] = OriginalPosition,
                    [145] = BodyFrontAttachment,
                    [146] = OriginalPosition,
                    [147] = BodyBackAttachment,
                    [148] = OriginalPosition,
                    [149] = NeckAttachment,
                    [150] = OriginalPosition,
                    [151] = AvatarPartScaleType,
                    [152] = OriginalSize,
                    [153] = UpperTorso,
                    [154] = Waist,
                    [155] = LeftLowerArm,
                    [156] = LeftElbowRigAttachment,
                    [157] = OriginalPosition,
                    [158] = LeftWristRigAttachment,
                    [159] = OriginalPosition,
                    [160] = AvatarPartScaleType,
                    [161] = OriginalSize,
                    [162] = LeftLowerArm,
                    [163] = LeftElbow,
                    [164] = Head,
                    [165] = FaceControls,
                    [166] = Head,
                    [167] = NeckRigAttachment,
                    [168] = OriginalPosition,
                    [169] = FaceFrontAttachment,
                    [170] = OriginalPosition,
                    [171] = HatAttachment,
                    [172] = OriginalPosition,
                    [173] = HairAttachment,
                    [174] = OriginalPosition,
                    [175] = FaceCenterAttachment,
                    [176] = OriginalPosition,
                    [177] = AvatarPartScaleType,
                    [178] = SurfaceAppearance,
                    [179] = Neck,
                    [180] = OriginalSize,
                    [181] = HeadWeld,
                    [182] = LeftUpperArm,
                    [183] = LeftShoulderRigAttachment,
                    [184] = OriginalPosition,
                    [185] = LeftElbowRigAttachment,
                    [186] = OriginalPosition,
                    [187] = LeftShoulderAttachment,
                    [188] = OriginalPosition,
                    [189] = AvatarPartScaleType,
                    [190] = OriginalSize,
                    [191] = LeftUpperArm,
                    [192] = LeftShoulder,
                    [193] = RightHand,
                    [194] = RightWristRigAttachment,
                    [195] = OriginalPosition,
                    [196] = RightGripAttachment,
                    [197] = OriginalPosition,
                    [198] = AvatarPartScaleType,
                    [199] = OriginalSize,
                    [200] = RightHand,
                    [201] = RightWrist,
                    [202] = RightLowerArm,
                    [203] = RightElbowRigAttachment,
                    [204] = OriginalPosition,
                    [205] = RightWristRigAttachment,
                    [206] = OriginalPosition,
                    [207] = AvatarPartScaleType,
                    [208] = OriginalSize,
                    [209] = RightLowerArm,
                    [210] = RightElbow,
                    [211] = RightUpperArm,
                    [212] = RightShoulderRigAttachment,
                    [213] = OriginalPosition,
                    [214] = RightElbowRigAttachment,
                    [215] = OriginalPosition,
                    [216] = RightShoulderAttachment,
                    [217] = OriginalPosition,
                    [218] = AvatarPartScaleType,
                    [219] = OriginalSize,
                    [220] = RightUpperArm,
                    [221] = RightShoulder,
                    [222] = LeftFoot,
                    [223] = LeftAnkleRigAttachment,
                    [224] = OriginalPosition,
                    [225] = LeftFootAttachment,
                    [226] = OriginalPosition,
                    [227] = OriginalSize,
                    [228] = AvatarPartScaleType,
                    [229] = LeftFoot,
                    [230] = LeftAnkle,
                    [231] = LeftLowerLeg,
                    [232] = LeftKneeRigAttachment,
                    [233] = OriginalPosition,
                    [234] = LeftAnkleRigAttachment,
                    [235] = OriginalPosition,
                    [236] = OriginalSize,
                    [237] = AvatarPartScaleType,
                    [238] = LeftLowerLeg,
                    [239] = LeftKnee,
                    [240] = LeftUpperLeg,
                    [241] = LeftHipRigAttachment,
                    [242] = OriginalPosition,
                    [243] = LeftKneeRigAttachment,
                    [244] = OriginalPosition,
                    [245] = OriginalSize,
                    [246] = AvatarPartScaleType,
                    [247] = LeftUpperLeg,
                    [248] = LeftHip,
                    [249] = RightFoot,
                    [250] = RightAnkleRigAttachment,
                    [251] = OriginalPosition,
                    [252] = RightFootAttachment,
                    [253] = OriginalPosition,
                    [254] = AvatarPartScaleType,
                    [255] = OriginalSize,
                    [256] = RightFoot,
                    [257] = RightAnkle,
                    [258] = RightLowerLeg,
                    [259] = RightKneeRigAttachment,
                    [260] = OriginalPosition,
                    [261] = RightAnkleRigAttachment,
                    [262] = OriginalPosition,
                    [263] = AvatarPartScaleType,
                    [264] = OriginalSize,
                    [265] = RightLowerLeg,
                    [266] = RightKnee,
                    [267] = LeftHand,
                    [268] = LeftWristRigAttachment,
                    [269] = OriginalPosition,
                    [270] = LeftGripAttachment,
                    [271] = OriginalPosition,
                    [272] = AvatarPartScaleType,
                    [273] = OriginalSize,
                    [274] = LeftHand,
                    [275] = LeftWrist,
                    [276] = RightUpperLeg,
                    [277] = RightHipRigAttachment,
                    [278] = OriginalPosition,
                    [279] = RightKneeRigAttachment,
                    [280] = OriginalPosition,
                    [281] = AvatarPartScaleType,
                    [282] = OriginalSize,
                    [283] = RightUpperLeg,
                    [284] = RightHip
                 }  -  Client - TEST:6

This is what it printed.

Alright so in this, it doesn’t say NumberBack. Which could really only mean one thing that NumberBack does not in fact exist at all. Can you see it from the explorer?

Yes, I see it from explorer.
image

How are you creating the Gui? Can you send us the code that you use to clone the things in ReplicatedStorage?