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

How to fix inifite yeild possible on this line of code?

Error: Infinite yield possible on 'Players.ivan6361.PlayerGui.ExitGui.Frame.TextButton:WaitForChild("TextButton")'

local hum = game.Players:FindFirstChild("Humanoid")

local frame = script.Parent:WaitForChild("TextButton").TextButton.Parent.Frame wait() local open = false

script.Parent.MouseButton1Click:Connect(function() if frame.Visible == false then frame.Visible = false else frame.Visible = false end end)

1 answer

Explanation

The reason the output is printing 'Players.ivan6361.PlayerGui.ExitGui.Frame.TextButton:WaitForChild("TextButton")' is because you have defined a variable for TextButton when the local script is the parent of the TextButton already.

Problem

local frame = script.Parent:WaitForChild("TextButton").TextButton.Parent.Frame 

If your script is inside a text button, you don't have to define this variable..

Possible solution

Assuming that you want a frame to appear when the TextButton is clicked, then the script would be as follows;

local hum = game.Players:FindFirstChild("Humanoid")

local frame = script.Parent.Parent:WaitForChild("Frame")

wait(.55) -- You can cut this if you don't want a delay

local open = false

script.Parent.MouseButton1Click:Connect(function()
	if frame.Visible == false then
       frame.Visible = true
	else
		frame.Visible = false
	end
end)

I hope this helps you and please up vote and select this as your answer if it did so..

1 comment

0

If you don't want the frame to appear, please let me know. I've just assumed this as you didn't said anything about what to appear or what not..

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