Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i make a group invite button for in game groups?

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)

1 answer

✓ Accepted answer

Explanation

Your error is telling me that you are doing this from the server.

Playergui only exists on the client (because why the hell would you try to edit a user interface fro m the server)

Same with LocalPlayer

Solution

You should make a RemoteEvent, two localscripts and a server script, then on one localscript fire a remotevent when the invite button is clicked then on the server fire another remotevent to tell the other localscript that it should display the invite.

Side Note

If you didn't understand the solution, you should follow tutorials and learn how to code properly before trying to make a game.

2 comments

0

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....

0

As in trying to make a serious game that would profit, not pong @minecraftjul

This discussion is preserved as it was. New answers, comments, and votes are closed.