Hello, I need help with making a script that will allow the player to type a command in chat, like /party “Player” and /partyaccept “Player”, I have no clue how I would do a system like this, and I cannot do anything GUI related because the game is in first person. Also how would I detect if not all party members are at the end of an area, like “All party members must be present to proceed to the next area”
Edit: Here are the scripts I have made, though they are kinda confusing lol
Script in ServerScriptService
local partyinvite = "/party "
local partyaccept = "/partyaccept "
local partyleave = "/partyleave"
game.Players.PlayerAdded:Connect(function(player)
local invite = false
local invited = false
local party = false
player.Chatted:Connect(function(msg)
if msg:sub(1, partyinvite:len()):lower() == partyinvite:lower() then
local playername = msg:sub(partyinvite:len() + 1)
if playername == player.Name then
game.ReplicatedStorage.PartyInviteSelf:FireClient(player)
else
local playeer = game.Players:FindFirstChild(playername)
if playeer == nil then
game.ReplicatedStorage.PlayerNoExist:FireClient(player)
else
if playeer.Name == playername and invited == false then
invited = true
game.ReplicatedStorage.PartyInvite:FireClient(playeer,player)
game.ReplicatedStorage.PartyInvited:FireClient(player,playeer)
wait(30)
invited = false
elseif playeer.Name == playername and invited == true then
game.ReplicatedStorage.PlayerAlreadyInvited:FireClient(player)
end
end
end
end
game.ReplicatedStorage.PartyAccept.OnServerEvent:Connect(function(playerr,Player)
if playerr == player then
invite = true
end
end)
game.ReplicatedStorage.PartyAccepted.OnServerEvent:Connect(function(player)
party = true
end)
if msg:sub(1, partyaccept:len()):lower() == partyaccept:lower() then
if invite then
local playername = msg:sub(partyaccept:len() + 1)
local playeer = game.Players:FindFirstChild(playername)
if playeer == nil then
game.ReplicatedStorage.PlayerNoExist:FireClient(player)
else
party = true
invite = false
game.ReplicatedStorage.PartyAccepted:FireClient(player,playeer)
game.ReplicatedStorage.InvitedPlayerAccepted:FireClient(playeer,player)
end
else
game.ReplicatedStorage.NoPartyInvite:FireClient(player)
end
end
if msg:lower() == partyleave:lower() then
if party == true then
invite = false
party = false
game.ReplicatedStorage.PlayerLeave:FireClient(player)
else
game.ReplicatedStorage.NotInParty:FireClient(player)
end
end
end)
end)
LocalScript in StarterPlayerScripts
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local MESSAGE_COLOR1 = BrickColor.new("Gold").Color
local MESSAGE_COLOR2 = BrickColor.new("Crimson").Color
local MESSAGE_COLOR3 = BrickColor.new("Lime green").Color
local MESSAGE_COLOR4 = BrickColor.new("Deep orange").Color
local remoteEvent1 = ReplicatedStorage:WaitForChild("PartyInvite")
local remoteEvent2 = ReplicatedStorage:WaitForChild("NoPartyInvite")
local remoteEvent3 = ReplicatedStorage:WaitForChild("PartyAccepted")
local remoteEvent4 = ReplicatedStorage:WaitForChild("PartyInvited")
local remoteEvent5 = ReplicatedStorage:WaitForChild("PlayerAlreadyInvited")
local remoteEvent6 = ReplicatedStorage:WaitForChild("PlayerNoExist")
local remoteEvent7 = ReplicatedStorage:WaitForChild("PartyInviteSelf")
local remoteEvent8 = ReplicatedStorage:WaitForChild("PlayerLeave")
local remoteEvent9 = ReplicatedStorage:WaitForChild("NotInParty")
local remoteEvent10 = ReplicatedStorage:WaitForChild("InvitedPlayerAccepted")
local playerr = game.Players.LocalPlayer
local function NotifyPlayer(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You have been invited by "..player.Name.." to join their party! Type /partyaccept "..player.Name.." to join their party.",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR1,
game.ReplicatedStorage.PartyAccept:FireServer(player)
})
end
local function NoInvite(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You have not been invited to a party!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR2,
})
end
local function AcceptedPlayerInvite(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You are now in "..player.Name.."'s party!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR3,
game.ReplicatedStorage.PartyAccepted:FireServer(player)
})
end
local function InvitedPlayerAccepted(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name.." has joined your party!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR3,
})
end
local function PlayerInvited(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You have invited "..player.Name.." to join your party!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR3,
})
end
local function PlayerAlreadyInvited()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You have already invited this player!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR4,
})
end
local function PlayerNoExist()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "This player does not exist or you typed their name incorrectly!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR2,
})
end
local function PartyInviteSelf()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You can't invite yourself.",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR4,
})
end
local function NotInParty()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You can't leave the party, because you aren't in one.",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR4,
})
end
local function PartyLeave()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "You have left the party.",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR4,
})
end
local function PartySomeoneLeft(player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "This player does not exist or you typed their name incorrectly!",
Font = Enum.Font.Cartoon,
Color = MESSAGE_COLOR2,
})
end
remoteEvent1.OnClientEvent:Connect(NotifyPlayer)
remoteEvent2.OnClientEvent:Connect(NoInvite)
remoteEvent3.OnClientEvent:Connect(AcceptedPlayerInvite)
remoteEvent4.OnClientEvent:Connect(PlayerInvited)
remoteEvent5.OnClientEvent:Connect(PlayerAlreadyInvited)
remoteEvent6.OnClientEvent:Connect(PlayerNoExist)
remoteEvent7.OnClientEvent:Connect(PartyInviteSelf)
remoteEvent8.OnClientEvent:Connect(PartyLeave)
remoteEvent9.OnClientEvent:Connect(NotInParty)
remoteEvent10.OnClientEvent:Connect(InvitedPlayerAccepted)