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

[SOMEONE HELP PLS??!!] Server isn't detecting the gui inside playergui?

Asked by
AltNature 169
5 years ago
Edited 5 years ago

I don't know what it is about these lines of code, but the server just doesn't agree with them or something. I can even check while testing the game whether or not the "pressEgui" is in PlayerGui ; it is! Im so flabbergasted i need help.

    --// Variables \\--

local part = game.Workspace.Part

local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()



--gui variables

local eGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui").pressEgui.eGui

local basic = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui").ChooseDifficulty.BasicButton

--// Actions \\--



part.Touched:Connect(function()

if plr.Seated == true then

eGui.Visible = true

end

end)



mouse.KeyDown:Connect(function(Key)

if Key == "e" then

basic.Visible = true

end

end)



basic.MouseButton1Click:Connect(function()

basic.Visible = false

end)

Tysm! error ; pressEgui is not a valid member of playergui

0
Is this a local script? You can only mention PlayerGui inside a localscript. AviaCheddar 41 — 5y
0
The server doesnt know who the localPlayer is, and GUIs are cloned from StarterGui to PlayerGui locally theking48989987 2147 — 5y
0
Double check the spelling of the code and the actual GUI MusicalDisplay 173 — 5y
0
Checked the spelling ; this isn't the whole script. AltNature 169 — 5y
View all comments (2 more)
0
its whole now C: AltNature 169 — 5y
0
Is this a Script or a LocalScript and where is it located? Spjureeedd 385 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

By what I currently see, you are trying to define Player by using "LocalPlayer" in a server script, I don't know why you'd even do that, but that is incorrect, there's also no way to get the mouse object while server-sided.

You also shouldn't expect changes to GUIs or even new GUIs created by the client to be replicated over to the server, so any changes you do VIA a LocalScript will stay local in this case.

0
I don't believe this is the issue here, if this was written in a server script it would error that "plr" is a nil value before it would error that pressEgui is not a valid member of PlayerGui MegaManSam1 207 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

The issue here is that your script can't find pressEgui because it does not instantly go to the PlayerGui when the script fires. On line 13 and 15, where you have,

    :WaitForChild("PlayerGui")

this WaitForChild function is not necessary to use on "PlayerGui" because it already exists within the player. To fix your error, you should move your WaitForChild function to right after the PlayerGui. Example:

plr.PlayerGui:WaitForChild("pressEgui")

this should fix the entire issue, but just to be safe you can do the same with line 15. Hope this helps!

Answer this question