Making a gui pop up when a player invites them

Im making a party system that when you invite them they get a pop up.

i wanted to know if this script could work since i currently have no one to test it with.

im new to using remote events and would like to know if the players gui could be made visible from the server itself

local script:

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local InvitePrompt = ReplicatedStorage:WaitForChild("InvitePrompt")
local InviteTo = script.Parent.Text

script.Parent.MouseButton1Click:Connect(function()
	InvitePrompt:FireServer(InviteTo)
	end)

server script:

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local InvitePrompt = ReplicatedStorage:WaitForChild("InvitePrompt")

InvitePrompt.OnServerEvent:Connect(function(player, InviteTo)
	game.Players:FindFirstChild(InviteTo).PlayerGui.Teams.Invited.Visible = true
	game.Players:FindFirstChild(InviteTo).PlayerGui.Teams.Invited.TextLabel.Text = (player.Name.. " has invited you to their party")
end)
1 Like

I mean you also use RemoteEvents as ClientEvents, by sending the event to the client from the server which would be easier since it doesn’t change for everyone on the server (Just optimization kinda)

(RemoteEvent | Roblox Creator Documentation)
(RemoteEvent | Roblox Creator Documentation)

Also recommend that you check if the InviteTo is the player so that they don’t invite themself

if InviteTo == player.Name then
  --  --
end

i dont understand what i have to do with the client events

do i just do:

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local InvitePrompt = ReplicatedStorage:WaitForChild("InvitePrompt")

InvitePrompt.OnServerEvent:Connect(function(player, InviteTo)
    InvitePrompt:FireClient(InviteTo)
end)

Yes just like that but with 2 args (InviteTo, player), and in StarterPlayerScripts as a LocalScript you would have something like this.

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local InvitePrompt = ReplicatedStorage:WaitForChild("InvitePrompt")

InvitePrompt.OnClientEvent:Connect(function(player)
   game.Players.LocalPlayer.PlayerGui.Teams.Invited.Visible = true
   game.Players.LocalPlayer.PlayerGui.Teams.Invited.TextLabel.Text = player.Name .. " has invited you to their party"
end)

the gui doesnt appear when i click on the invite button the gui appears on my screen