Hello all,
I was making a player party system with tables and was trying to figure out how to add players to the table of a players party when they clicked a button. When I was trying to insert the player into the table it works for the client clicking the button but not the party leader. What am I doing wrong with my code?
This remote event is put into another OnServerEvent (function?) and then that is :FireServer(d?) on another client script.
local CreatePartyEvent = game.ReplicatedStorage.Events.CreatePartyEvent
local player = game.Players.LocalPlayer
CreatePartyEvent.OnClientEvent:Connect(function(PartyLeader)
local PartyButton = game.ReplicatedStorage.ScreenAssets.PartyButton:Clone()
local players = game.Players:GetChildren()
local playerPartyFolder = Instance.new("Folder", workspace.Parties)
local folderofNames = playerPartyFolder:GetChildren()
table.insert(folderofNames, PartyLeader)
playerPartyFolder.Name = (tostring(PartyLeader) .. "'s Party")
PartyButton.Parent = player.PlayerGui.MainMenu.Menu.PartyFrame.ScrollingFrame
PartyButton.MouseButton1Click:Connect(function()
if not table.find(folderofNames, player) then
table.insert(folderofNames, player)
else
print(folderofNames)
end
end)
PartyButton.Name = tostring(PartyLeader)
PartyButton.Text = (tostring(PartyLeader) .. "'s Party")
end)
Thank you,
Ultan