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

Help with filtering enabled?

Hey everyone, I am attempting to reduce exploiters in my game by using filtering enabled, one issue I have found is that startergui wont copy over to playergui (I assume the same happens with starterpack although I can think of an easy workaround for that). I attempted to do this:

player.CharacterAdded:connect(function(character)
	for i,v in pairs(game:GetService("StarterGui"):GetChildren()) do
		v:clone().Parent = player:WaitForChild("PlayerGui")
	end
end)

with no success, any ideas?

8 comments

1

Why user CharacterAdded when you can use PlayerAdded? Try PlayerAdded. Also, anything in the output?

0

Nothing

0

Is that your entire script?

0

nope

2

Post the uppermost function that this is nested inside of. FilteringEnabled doesn't stop Server to Client replication, only Client to Server, so the StarterGui should be being copied over.

0

Sorry, tried the playeradded thing and it worked, for whatever reason I assumed that the playergui replicated with every character addition, sorry for not commenting earlier.

1

Yeah, for future reference, every time a Player's Character is added, unless teh ResetPlayerGuiOnSpawn property is ticked, they will get a copy of the current contents of StarterGui added to their PlayerGui. If that property is unticked, the old contents will be removed and then the startergui contents will be added.

0

cheers

1 answer

I had the very same problem so I am using this script which fixes the problem:- This script is in ServerScriptService and my gui is in the workspace

function onHumanoidDied(property, plr)
	
	plrGui = plr.PlayerGui:FindFirstChild("ScreenGui")
	
	if plr~= nil and plrGui~=nil then	
		plr.PlayerGui.ScreenGui:Destroy()
	end
	
end

function onPlayerRespawn(property, plr)
	
        while plr and plr.Parent do
            	if plr.Character then break end
            wait(1)
        end

        if not (plr and plr.Parent) then return end

   wait(1)
	if game.Workspace.FilteringEnabled then
		game.Workspace.FilteringEnabled = false
		wait(1)
		Workspace.ScreenGui:Clone().Parent = plr.PlayerGui
		game.Workspace.FilteringEnabled = true
	else
		game.Workspace.FilteringEnabled = true
	end
    
end

function onPlayerEntered(plr)

		while plr and plr.Parent do
            if plr.Character then break end
            wait(1)
		        end
       if not (plr and plr.Parent) then return end

		wait(1)
		Workspace.ScreenGui:Clone().Parent = plr.PlayerGui
		
		plr.CharacterRemoving:connect(function(property) onHumanoidDied(property, plr) end)
        plr.CharacterAdded:connect(function(property) onPlayerRespawn(property, plr) end)

end
game.Players.PlayerAdded:connect(onPlayerEntered)

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