So im making a party script where u have a list to join people.
when you create a party it sends the data to a RemoteEvent and then a server script loops through the players and access their PlayerGui to then clone an invisible tab and make it visibe.
But when there is an existing party tab but a player joins after you made the party it doesnt show / exist.
here is my script:
local RS = game:GetService("ReplicatedStorage")
local PC = RS:WaitForChild("PartyCreate")
local Plr = game:GetService("Players")
repeat
task.wait()
until #Plr:GetChildren() > 0
local function Player()
local Plrs = Plr:GetChildren()
return Plrs
end
Plr.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(Player())
end)
local Plrs = Player()
PC.OnServerEvent:Connect(function(plr, Name, PlrCount, Privacy)
for _, player in ipairs(Plrs) do
local Parties = player:WaitForChild("PlayerGui").Parties
local party = Parties.ScrollingFrame.Parties
local newparty = party:Clone()
newparty.Parent = Parties.ScrollingFrame
newparty.Visible = true
local nametxt = newparty.PartyName
local Plrtxt = newparty.PlayerCount
nametxt.Text = tostring(Name)
Plrtxt.Text = "1/"..PlrCount
end
end)
Are u even sending a signal to the server when a player press join party button or something? As long as I know the script you gave only creates a party UI.
Hey, Just a question… You are saying that you are handling parties only by gui? and not like making a table and saving it somewhere in the script so other players can join the party or something?
Cause if you are handling party joins and invites thorugh gui only then that’s a bad idea.
something like this :
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local PCEvent = RS:WaitForChild("PartyCreate") -- // Party Create RemoteEvent
local parties = {} -- Holds all parties that have been created
-- // -- // -- // -- // -- // -- // -- // -- // -- // -- // -- // --
local function updateGuiStats(partyId)
local partyInfo = {
OwnerId = partyId,
memebersId = parties[partyId].members,
hidden = parties[partyId].hidden or false
}
PCEvent:FireAllClients(partyInfo)
end
local function createParty(owner : Player)
parties[owner.UserId] = {
memebers = {owner.UserId},
hidden = false,
}
return parties[owner.UserId]
end
local function joinPlayerToParty(player : Player, partyId : number)
-- Other codes to make the player leave their current party
table.insert(parties[partyId], player.UserId)
end
local function invitePlayerToParty(playerToInvite : Player, partyId : number)
end
local function partyCleanUp(partyId : number)
end
-- // -- // -- // -- // -- // -- // -- // -- // -- // -- // -- // --
PCEvent.OnServerEvent:Connect(createParty)
game.Players.PlayerAdded:Connect(function(plr)
for partyId, partyInfo in parties do
updateGuiStats(partyId)
end
end)
This is not the best way but it works. Then in a localscript you update your UI. I haven’t tested the code yet…