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

Script fired by a remote event can't find a child of PlayerGui ?

Asked by
R_ngar 10
5 years ago

Hello guys, So I am trying to do something like this

script.Parent.GetButtonRemoteEvent.OnServerEvent:Connect(function(plr, test)
    local gui = game.Lighting.Folder.TestButton:Clone()
    gui.Parent = plr.PlayerGui.TestFrames.Frame.ScrollingFrame
    gui.Test.Value = true
end)

It says "TestFrames is not a valid member of PlayerGui" when it actually is. It is in PlayerGui but for some reason it can't find it.

Please, help

0
Don't use lighting as storage. And use a remote event on the client, not the server. User#24403 69 — 5y
0
Listen for the event OnClientEvent from the client , and fire from the server User#24403 69 — 5y

1 answer

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

You are trying to access the ScreenGui from a server script. ScreenGuis cloned from StarterGui to PlayerGui are not replicated to the server, therefor you cannot use them from a server script.

You need to either use RemoteEvents to tell the client when to modify the gui or clone the gui from a server script into the PlayerGui, then it will be accessible by server, although it's a less recommended way.

(Note this answer is a copy/paste of my other answer, because I've already typed the same thing at least 4 times this week and I have no idea how to reword it anymore to make it not look the same xd)

Ad

Answer this question