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

Why Doesn't this recognize "PlayerGui" as a member of "Player"?

Asked by 8 years ago

I'm trying to create a party request script but whenever i run the script. it says that "PlayerGui" isn't a member of "Player". if somebody can help i'd really appreciate it . Thx :D

Button = script.Parent

Button.MouseButton1Down:connect(function()
    local PName = script.Parent.Parent.PlayerName   
    local Player = game.Players[PName.Value]
    local You = game.Players.LocalPlayer
    script.Parent.Parent.Visible = false 
    if not Player.PlayerGui:FindFirstChild("Invite") then
        local gui = script.Invite:clone()
        gui.Parent = Player.PlayerGui
        gui.PlayerName.Value = PName.Value 
        gui.InviterName.Value = You.Name 
        gui.Frame.Visible = true 
        gui.Frame.lblText.Text = "Invite from ".. You.Name
    end 
end)
0
This could either be one of two problems: (1) Your game is FilteringEnabled, so you can't access other players' PlayerGuis (look at my answer below if that is the case). nilVector 812 — 8y
0
or (2) Your game is not FilteringEnabled, and the script is just running before the PlayerGui of a player loads. If that's the case, ignore my answer below, and just use Player:WaitForChild("PlayerGui") instead of Player.PlayerGui. nilVector 812 — 8y
0
My friend was using something exactly like this the other day to create teams and then invite players to them. He needed my help and I fixed what he had. MrLonely1221 701 — 8y

1 answer

Log in to vote
1
Answered by
nilVector 812 Moderation Voter
8 years ago
Edited 8 years ago

If your game is FilteringEnabled, you cannot access another player's PlayerGui locally through a LocalScript.

What I would recommend you to do is to keep up with parties (like who's in a party, maximum amount of people, etc.) with StringValue objects and other objects such as Folders and IntValues (or whatever else you for providing information of a party in a GUI) inside of Workspace.

You have to use RemoteFunctions and RemoteEvents (here's the wiki page) accordingly to talk to Workspace (such as when you want to add a person to a party when he/she clicks a specific GUI).

However, you DON'T need to use RemoteFunctions or RemoteEvents when you just want to read a value. For example, if you have a StringValue named "PlayerName" inside a party Folder called "Party1" in Workspace, you can just do this from the client to retrieve the player's name:

local name = game.Workspace.Party1.PlayerName.Value

Hope this helps!

Ad

Answer this question