As with a lot of other posts, this problem is not in test mode but rather in the Roblox "Play" mode. I have a server script that will detect when a player is inside the part "ENTERSHOP" and will make the player's shop GUI visible. When the script detects a player in the Roblox server mode, it is seemingly unable to find the ScreenGui "Gui" as a child of PlayerGui and throws an "Infinite yield possible" error relating to line 10
local part = script.Parent local debounce = false part.Touched:connect(function(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild('Humanoid') then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if plr.PlayerGui:WaitForChild("Gui").Shop.Visible ~= true then plr.PlayerGui:WaitForChild("Gui").Shop.Visible = true end end end debounce = false end end) part.TouchEnded:connect(function(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild('Humanoid') then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if plr.PlayerGui:WaitForChild("Gui").Shop.Visible ~= false then plr.PlayerGui:WaitForChild("Gui").Shop.Visible = false end end end debounce = false end end)
I know that the scripts are a little sloppy but I plan on cleaning it up after the bugs are fixed.
In Studio's Play Solo mode (when you hit Play), there is no separation of client and server. This means that the client and server can do things in it that they really shouldn't be able to. Use Test Server mode to simulate a live server. Check that your scripts are in the correct containers, and that the server is not trying to do something client-only, and vice versa.
In this specific case, it's important to remember that when the client parents something to Player.PlayerGui
, it is not replicated. Instead, you should listen to BasePart.Touched
client-side, since all you're doing is adding latency by doing this server-side.
Also, RBXScriptSignal:connect()
is deprecated, prefer RBXScriptSignal:Connect()
instead.
Also, no need to check for a humanoid, just call game.Players:GetPlayerFromCharacter()
as you're doing without the humanoid check.