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.
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