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

Remote Event error GateGUI is not a valid member of PlayerGui?

I have this GUI that allows players to open/close a gate. You must stand on this block for the GUI to show up, I've been getting this error whenever I stand on it.

GateGUI is not a valid member of PlayerGui Stack Begin Script 'Workspace.Part.Script', Line 3 Stack end

I have a remote event called 'Gate' In replicated Storage.

In the block you must stand on I have a local script, here is the code:

script.Parent.Touched:connect(function(hit)
    game.ReplicatedStorage.Gate:FireServer(hit)
end)

After that I have a script in ServerScript service, here is the code:

game.Workspace.Gate.OnServerEvent:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
        game.Players[hit.Parent.Name].PlayerGui.GateGUI.Box.Visible = true
    end
end)

Any help would be appreciated.

2 comments

0

This is pretty self explanatory "GateGUI" is not in PlayerGui. Start up a test server and go to PlayerGui and see what happened to it.

0

The gui is in player gui but I still get the error.

1 answer

✓ Accepted answer

It's most likely because the GateGUI is placed in StarterGui and the game is Filtering Enabled.

If that's the case, the gui, once cloned, becomes a local instance, meaning only the player can see it, and the server cannot.

If you want to be able to access the gui directly from the server, you should store it i.e. in ServerStorage and use a script to copy it to players' playerguis upon join/part touch, like so:

local gui = game:GetService("ServerStorage").GateGUI

workspace.TheBlockYouNeedToStandOnForTheGuiToShow.Touched:Connect(function(hit)
	if hit.Parent.ClassName == "Model" and hit.Parent:FindFirstChildOfClass("Humanoid") then
		local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if not plr then return end
		gui:Clone().Parent = plr.PlayerGui
	end
end)

For everyone who thinks this won't work: yes, you can access the PlayerGui from a server script in FE, you can place a gui inside it and the player will see it.

1 comment

0

Can you friend me please?Theres an error in my script and i might need your help.

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