I am making a script where player1 clicks player2 then player2 has a gui pop up. Under StarterPlayerScripts I have a local script with:
--// Services
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
--// Objects
local player = players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
print("test1")
local subject = players:GetPlayerFromCharacter(mouse.Target.Parent)
if Player and Player.TeamColor.Name == ("Dirt brown") then
replicatedStorage:WaitForChild("SellPistol"):FireServer(subject)
end
end)
replicatedStorage:WaitForChild("SellPistol").OnClientEvent:Connect(function(subject)
subject:WaitForChild("PlayerGui").StartScreen.Frame.Visible = true
print("test3")
end)
and under ServerScriptService I have:
--// Services
local replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage:WaitForChild("SellPistol").OnServerEvent:Connect(function(player,subject)
print("test2")
game:GetService("ReplicatedStorage"):WaitForChild("SellPistol"):FireClient(player,subject)
end)
The result is:
Infinite yield possible on 'Players.example:WaitForChild("PlayerGui")'
--local script line 18
What does this mean?

1 comment
https://scriptinghelpers.org/questions/64146/whats-an-infinite-yield-why-is-this-happening