I'm relatively new to scripting, so I'm sorry if some of these questions suck, haha. I've really enjoyed learning as much as I have so far. Anyway, as the title states, I'm working on a party Gui that you'd find in any mmo or regular rpg. However, I'm having a bit of trouble, and all the help I could get would be really appreciated!
Here's a bit of the script that I whipped up:
print("partyGui loaded") main = script.Parent player = main.Parent.Parent.Parent character = player.Character local players = game.Players:GetChildren() invOptions = main.invOptions plr1 = player plr2 = main.partyActive.plr2 plr3 = main.partyActive.plr3 plr4 = main.partyActive.plr4 inviteMenu = main.partyActive.invite invGui = main.invPlayer invButton = invGui.invite cancelbutton = invGui.cancel invButton.MouseButton1Click:connect(function() if plr2.Visible == false and invGui.playerName.Text ~= "Type name here" then local a = tostring(invGui.playerName.Text) invClone = invOptions:Clone() invClone.Parent = players.a invClone.Visible = true invGui.invInfo.Text = "Player has been invited!" wait(1) invGui.invInfo.Text = ("Sending invitation to " ..a) wait(1) invGui.Visible = false plr2.Visible = true plr2.Text = (""..a) else invGui.invInfo.Text = "Player does not exist!" wait(2) invGui.invInfo.Text = "Type the player's name below!" end end) inviteMenu.MouseButton1Click:connect(function() if invGui.Visible == true then print("Already open!") elseif invGui.Visible == false then wait(.25) invGui.Visible = true print("Opening menu!") end end)
https://gyazo.com/60738890927fbdf5f0c5ffcc0ac78d30 (Controller is the name of the script)
So, what I need help with are firstly, getting invClone to be copied and made visible for the person that was invited, so that they can accept or decline the invitation to join someone's party. As you can see, I tried to make invClone.Parent equal to the text of invGui.playerName, which is a text box (the idea is that you type the player's name there, then hit the invite button). However, this doesn't seem to work, and I have absolutely no idea how to fix it. There are no errors in output or anything.
Secondly, is there some way that I can have the script check to see if the person being invited is an actual player in the server? Right now, I have it so that if the text of the playerName text box is at it's default ("Type name here"), the text label invInfo will change to "Player does not exist!". What I need is to get that to occur every time someone tries to invite a player that actually doesn't exist, whether the player isn't in that server, or they misspelled their username.
https://gyazo.com/12acc278cd60f9bec44312bab50c10dc https://gyazo.com/12acc278cd60f9bec44312bab50c10dc (what plr2 looks like, not sure if that'll help any.)
Thirdly, I'm going to need to get the party to update for both people (meaning the person who joins the party will have the gui show up and all that, but the person who invited them will be 'player two', I guess?), and I need that to be dependent on whether the person who was invited accepted the invitation, or declined it. Any ideas on how I can make that happen?
Hopefully that all made sense! Thanks in advance!
gui:Clone().Parent = game.Players.Monsieur_Robert.PlayerGui -- Moves a clone of the GUI into Monsieur_Robert's player gui. This GUI will be displayed on their screen.
if game.Players:FindFirstChild("Monsieur_Robert") then -- If nil (player is not in players), this if statement will return false. print("Player Monsieur_Robert exists.") end