I made a gui to create your own group within a game and I need to make a invite button so other people can invite another player to that group, and i tested this script but it doesn't seem to work, and the error seems to say playergui is not a valid member of player.
local plr = game.Players.LocalPlayer
local stats = plr:WaitForChild("leaderstats")
local group = stats:WaitForChild("Affiliation")
local money = stats:WaitForChild("Money")
local nameofgroup = script.Parent.Parent:WaitForChild("NameGroup")
local otherplayer = script.Parent.Parent:WaitForChild("InvitePlayerName")
script.Parent.MouseButton1Click:connect(function()
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name == otherplayer.Text then
local pgui = v:WaitForChild("PlayerGui")
local groupframe = pgui:WaitForChild("GroupGUI"):WaitForChild("GroupFrame")
local joinframe = groupframe:WaitForChild("JoinFrame")
local clone = game.ReplicatedStorage["JoinGroup"]:Clone()
for j,k in pairs(clone:GetChildren()) do
if k.Name == "Name" then
k.Text = group.Value
end
clone.Parent = joinframe
end
end
end
end)

2 comments
If you just learn code without trying make a game you won't really test what your learning. If you do, you will remember it better. It is the same as trying to make a game while learning scripting. So....
As in trying to make a serious game that would profit, not pong @minecraftjul