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

Filtering Enabled - accessing Player GUI?

Alright so i have enabled filtering (i need to have it enabled dont) and i have a server script located in "ServerScriptService" in the game. This trys to acces the screengui entity in the Player's Gui but i dont think it works like that , i was wondering what its stopping it from working, thansk for any help ~bubs

function onPlayerEntered(player)
	 player.CharacterAdded:connect(function(character)
		local GUI = player.PlayerGui['Screen GUI'] -- error here "Screen GUI is not a valid member of playerGui" or something like that
		--....excess code down here (why the character parameter is needed ha)
	end)
end)
--(E.G) This is an example script of me trying to acces the GUI (similar to my one)

P.S - this works in Studio as well

1 answer

✓ Accepted answer

##Problem

What you're trying to do is access a object the server has no access to. Roblox has oriented the PlayerGui to be handled by the client and made this especially clear with FilteringEnabled environments. Basically the PlayerGui objects are invisible to the server.


##FilteringEnabled

What Filtering enabled ends up do is, it will prevent client script actions from being replicated to the server. It will also prevent the server from having control of client script actions such as the PlayerGui. Essentially what FilteringEnabled does is it protects the game from unintended changes from affecting players, and prevents the server from making potentially malicious changes to other clients (you know those password verification GUIs, that's their goal to prevent).


##Solution

You would want to have two scripts (or one depending on what you're trying to accomplish) and use RemoteEvents or RemoteFunctions. You would want the server to invoke or fire the client through the RemoteEvent or Function.

Once again, I have no idea what you're trying to accomplish so I can not assist you further. Hopefully this gave you some insight as to how FilteringEnabled works. If you have any questions, feel free to comment below.

2 comments

0

thanks. Basically, i have created cutom GUI bars that displays health and XP, and i need to it update when the xp is chanegd, or health is changed. But thanks for the help, i understand remote events n stuff, so ill try and implement it :3

0

Now the health bar you should be able to take humanoid's health from the LocalPlayer's character. XP depends on how you handle it. To prevent severe latency of events or functions it is recommended you try to keep client things client oriented, and server things server oriented.

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