FilteringEnabled and StarterGui #RobloxDev

One of the many “opportunities for improvement” about FilteringEnabled is that some things will appear to work in Studio but not on the client, which means you can’t trust what you see when you press play in Studio.

A big one is that anything you place in StarterGui replicates to the PlayerGui just fine in studio run mode, but not once you publish it and play it on the client.

So, I always have a script on my PlayerAdded that loops through the guis in StarterGui and replicates them to the player gui, if they’re not there already.

-- put this inside your PlayerAdded function
repeat wait() until player:FindFirstChild("PlayerGui")
for _, gui in pairs(game.StarterGui:GetChildren()) do
     if not player.PlayerGui:FindFirstChild(gui.Name) then
          local g = gui:Clone()
          g.Parent = player.PlayerGui
     end
end

To be honest I’ve pretty much stopped using StarterGui with my games at all (which are all FE). I usually put the guis into a folder in the workspace and then replicate them into the PlayerGui when needed.

One last thing on GUIs: in 99% of use cases I’ve come across you want to have StarterGui > ResetPlayerGuiOnSpawn unchecked. It’s checked by default, but  I usually want my guis to come back when a player respawns.

 

Sounds and FilteringEnabled #RobloxDev

Haven’t gotten to test this all that much but have found that the sound:Stop() does not do anything in client mode if FilteringEnabled is on and the sound is parented in the PlayerGui.

This is one of MANY MANY things I’ve found about FilteringEnabled that isn’t exactly mentioned in the documentation, and I don’t know if that’s because it’s really a problem or if there’s a solution I just haven’t been able to find through searching.

At any rate, I have two functions to handle sounds. One that creates the sound if it doesn’t exist (usually in player.PlayerGui) and then plays it. The other destroys it (sound:Destroy()). This is the only way so far I’ve been able to get sounds to stop in play mode.

I’ve also found that to get a sound to play more than once in the client (let’s say you want a cash register sound every time a player buys something) you first have to do

sound:Stop()
sound:Play()

.. instead of just sound:Play()

… though again – hopefully I’m just missing something and will find a better way someday.