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)

3 comments
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).
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.
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.