Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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.

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. oftenz 367 — 5y
0
The gui is in player gui but I still get the error. DogeDark211 81 — 5y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

0
Can you friend me please?Theres an error in my script and i might need your help. Danielp533 16 — 5y
Ad

Answer this question