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

0 I don't know whar's wrong with this if not FindFirstChild loop?

game.Players.PlayerAdded:connect(function(player)
 repeat wait() until player.PlayerGui:FindFirstChild("StartMenu")
 repeat wait() until player.Character:findFirstChild("Humanoid")
 
 player.PlayerGui.StartMenu.Frame.Visible = true
 player.Character.Humanoid.WalkSpeed = 0



while true do
wait(0.1)
if not player.Character:findFirstChild("StartMenu") then
 player.PlayerGui.ShopButton.Frame.Visible = true
 end
end

print('JoinedAndWorking!')
end)

player:WaitForChild('PlayerGui'):WaitForChild('ShopButton'):WaitForChild('Frame').Visible = true

worst localscript ive seen in a while.

4 comments

0

This is a Bad Question (TM). The while loop will never exit, so it will never print "JoinedAndWorking"

0

its FindFirstChild not findFirstChild and break your loop for god's sake

0

i can feel you judging me

0

Dude please indent it makes code a lot easier to read.

3 answers

✓ Accepted answer

Use WaitForChild like i did below its better to use.

game.Players.PlayerAdded:connect(function(player)
player.PlayerGui:WaitForChild("StartMenu")
player.Character:WaitForChild("Humanoid")

 player.PlayerGui.StartMenu.Frame.Visible = true
 player.Character.Humanoid.WalkSpeed = 0



while true do
wait(0.1)
if player.PlayerGui:FindFirstChild("StartMenu").Enabled then return 
	else player.PlayerGui.ShopButton.Frame.Visible = true
 end
end

print('JoinedAndWorking!')

player:WaitForChild('PlayerGui'):WaitForChild('ShopButton'):WaitForChild('Frame').Visible = true
end)




In your while loop you have to use a break to ensure it carry's on down the code. A break basically exits the loop and lets the rest of the code run, instead of yielding at that while loop.

game.Players.PlayerAdded:connect(function(player)
 repeat wait() until player.PlayerGui:FindFirstChild("StartMenu")
 repeat wait() until player.Character:findFirstChild("Humanoid")

 player.PlayerGui.StartMenu.Frame.Visible = true
 player.Character.Humanoid.WalkSpeed = 0



while true do
	wait(0.1)
	if not player.Character:findFirstChild("StartMenu") then
 		player.PlayerGui.ShopButton.Frame.Visible = true
		break
 	end
end

	print('JoinedAndWorking!')
end)

player:WaitForChild('PlayerGui'):WaitForChild('ShopButton'):WaitForChild('Frame').Visible = true

Accept if it helped

You can use a break, but You might as well just use a repeat loop.

game.Players.PlayerAdded:connect(function(player)
 repeat wait() until player.PlayerGui:FindFirstChild("StartMenu")
 repeat wait() until player.Character:findFirstChild("Humanoid")

 player.PlayerGui.StartMenu.Frame.Visible = true
 player.Character.Humanoid.WalkSpeed = 0



repeat
wait()
until player.Character:findFirstChild("StartMenu")
 player.PlayerGui.ShopButton.Frame.Visible = true
 print('JoinedAndWorking!')
end)

player:WaitForChild('PlayerGui'):WaitForChild('ShopButton'):WaitForChild('Frame').Visible = true


Just a suggestion, because checking for a break seems pretty pointless

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