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

[SOLVED] Why is GUI is not a valid member of PlayerGui?

Asked by 6 years ago
Edited 6 years ago

The script in ServerScriptService and FilteringEnabled is on.

Part of script:

function playerEnter(newPlayer)
    newPlayer:WaitForChild('PlayerGui')
    local p = newPlayer
    local userId = p.userId
    newPlayer.CharacterAdded:wait()
    repeat wait() until newPlayer.PlayerGui ~= nil
    print("Setting up " .. userId .. "'s resources.")
    newPlayer.PlayerGui.GUI.Loading.Visible = true
    newPlayer.PlayerGui.GUI.Loading.ItemName.Text = "Setting up " .. userId .. "'s resources."
    wait()
    local ranString = RandomString(20)
    local v = Instance.new("Model")
    v.Parent = game.ServerStorage.PlayerDataService
    v.Name = ranString

    --newPlayer.PlayerGui.UI.Main.PlayerDataService.Value = v

    local v1 = Instance.new("IntValue")
    v2.Parent = v
    v2.Name = "Credits"
    v2.Value = 0    

    local v2 = Instance.new("IntValue")
    v6.Parent = newPlayer
    v6.Name = "leaderstats"
    v6.Value = 0

    local v3 = Instance.new("IntValue")
    v16.Parent = v6
    v16.Name = "Rank"
    v16.Value = math.floor(v3.Value/1000)

    if game:GetService("GamePassService"):PlayerHasPass(newPlayer, 993313196) or newPlayer.Name == "zZGalaxySolarManZz" then
    local v6 = Instance.new("ObjectValue")
    v6.Parent = newPlayer
    v6.Name = "MVP"
    v6.Value = nil          
    end

Output: "GUI is not a valid member of PlayerGui"

Error line is 08: 'newPlayer.PlayerGui.GUI.Loading.Visible = true'

It's not working. Why?

0
Read my bio. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Since GUI's are mainly client only, the server (ServerScriptService) cannot access them or edit the contents within them. To make a GUI server wide, you need to use Remote Events. You can find tutorials of remote events on the Guide section of this website, or by browsing the wiki.

0
Solved, Thank you much. zZGalaxySolarManZz 49 — 6y
0
You're welcome! PyccknnXakep 1225 — 6y
Ad

Answer this question