I’m currently working on a party system and I’m trying to do the kicking part of it so the party leader can kick other players and this is what I have so far however for some reason it seems work just fine the first time but after this runs again it just doesn’t?
KickFromParty.OnServerEvent:Connect(function(Player,PlayerToKick)
local Party = PlayerManager:GetData(Player,"Party")
for i,Plr in pairs(Party["InParty"]) do
if Plr.Name == PlayerToKick then
table.remove(Party["InParty"],i)
PlayerManager:ChangeStat(Plr,"Party",{Host = "",InParty = {}})
DisbandParty:FireClient(Plr)
end
end
if #Party["InParty"] <= 1 then
print("Disband")
PlayerManager:ChangeStat(Party["InParty"][1],"Party",{Host = "",InParty = {}})
DisbandParty:FireClient(Party["InParty"][1])
else
print("Update Party")
for _,Plr in pairs(Party["InParty"]) do
PlayerManager:ChangeStat(Plr,"Party",Party)
KickedFromParty:FireClient(Plr,PlayerToKick)
end
end
end)
Output the first time you kick a player
Output the second attempt as you can see it doesn’t actually remove the player as it still ends up printing 2.
EDIT: I updated the script, but it still only works the first time
EDIT 2: Ok so turns out the issue wasn’t even because of this it was because of another function that added the player twice L.