I just started working on a party system for a fun a day ago, and I want to see if I can make any improvements to the current system. Feel free to point out any tweaks that I should make. Thank you!
Server Script:
-- By Sylvern
-- Party System
-- 4/5/2020
local Storage = game:GetService("ReplicatedStorage")
local Parties = Storage:WaitForChild("Parties")
local Event = Storage:WaitForChild("PartyEvent")
local CreationCooldown = false
local PassableActions = {
['CreateParty'] = true,
['DisbandParty'] = true,
['AddMember'] = true,
['LeaveParty'] = true,
}
game.Players.PlayerAdded:Connect(function(plr)
local isInParty = Instance.new("BoolValue", plr)
isInParty.Name = 'IsInParty'
isInParty.Value = false
end)
Event.OnServerEvent:Connect(function(plr, action, recruitMember)
local isInParty = plr:FindFirstChild('IsInParty')
local filterAction = PassableActions[action]
if not filterAction then
plr:Kick('Stop exploiting.')
end
if action == 'CreateParty' then
if CreationCooldown then return end
if isInParty.Value == false and not Parties:FindFirstChild(plr.Name.. 's Party') then
warn(plr.Name.. "'s Party has been created!")
local newParty = Instance.new("Folder", Parties)
newParty.Name = plr.Name.. 's Party'
local owner = Instance.new("StringValue", newParty)
owner.Name = 'Owner'
owner.Value = plr.Name
isInParty.Value = true
local partyEvent = Instance.new("RemoteEvent", newParty)
partyEvent.Name = 'PartyHandler'
CreationCooldown = true
wait(2)
CreationCooldown = false
else
warn('Your party already exists.')
end
end
if action == 'DisbandParty' then
if CreationCooldown then return end
if isInParty.Value == true and Parties:FindFirstChild(plr.Name.. 's Party') then
local PlrParty = Parties[plr.Name.. 's Party']
for _, partyMembers in pairs(PlrParty:GetChildren()) do
local getPlayers = game.Players:FindFirstChild(partyMembers.Name)
if not getPlayers then warn('This is a single party.')
isInParty.Value = false
PlrParty:Destroy()
warn('You party is been removed.')
CreationCooldown = true
wait(3)
CreationCooldown = false
return end
getPlayers('IsIartnPy').Value = false
end
isInParty.Value = false
PlrParty:Destroy()
warn('works')
CreationCooldown = true
wait(3)
CreationCooldown = false
end
end
if action == 'LeaveParty' then
end
if action == 'AddMember' then
end
end)
Local Script:
-- By Sylvern
-- Party System
-- 4/5/2020
local UI = script.Parent
local Player = game.Players.LocalPlayer
local Storage = game:GetService("ReplicatedStorage")
local Event = Storage:WaitForChild("PartyEvent")
local Parties = Storage:WaitForChild("Parties")
local DisbandBtn = UI:WaitForChild("DisbandBtn")
local CreateBtn = UI:WaitForChild("CreateBtn")
local LeaveBtn = UI:WaitForChild("LeaveBtn")
if Player:WaitForChild('IsInParty').Value == true then -- When the humanoid dies, it doesn't reset everything.
if Parties:FindFirstChild(Player.Name.. 's Party') then
local ownerParty = tostring(Parties[Player.Name.. 's Party'])
ownerParty = ownerParty:lower()
if ownerParty:find(Player.Name) then
DisbandBtn.Visible = true
end
end
LeaveBtn.Visible = true
CreateBtn.Visible = false
end
CreateBtn.MouseButton1Click:Connect(function()
Event:FireServer('CreateParty')
CreateBtn.Visible = false
DisbandBtn.Visible = true
end)
DisbandBtn.MouseButton1Click:Connect(function()
Event:FireServer('DisbandParty')
CreateBtn.Visible = true
DisbandBtn.Visible = false
end)
LeaveBtn.MouseButton1Click:Connect(function()
Event:FireServer('LeaveParty')
end)