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.
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.