Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService('ReplicatedStorage')
- local Knit = require(ReplicatedStorage.Packages.Knit)
- local PartyController = Knit.CreateController { Name = "PartyController" }
- local CurrentParty = nil
- local CurrentSelection = nil
- function PartyController:KnitInit()
- local Player = game:GetService('Players').LocalPlayer
- local UI = Player.PlayerGui:WaitForChild('ScreenGui').UI
- local PlayerLabel = UI.ScrollingFrame.Player
- local function CreateLabel(player)
- local tempPlayerLabel = PlayerLabel:Clone()
- tempPlayerLabel.Text = player.Name
- tempPlayerLabel.Name = player.Name
- tempPlayerLabel.Visible = true
- tempPlayerLabel.Parent = UI.ScrollingFrame
- tempPlayerLabel.MouseButton1Click:Connect(function()
- if CurrentSelection == player then
- local currentUI = UI.ScrollingFrame:FindFirstChild(CurrentSelection.Name)
- if currentUI then currentUI.BackgroundColor3 = Color3.new(255,255,255) end
- CurrentSelection = nil
- tempPlayerLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- else
- CurrentSelection = player
- tempPlayerLabel.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- end
- end)
- end
- --Fill in current players in game
- for i, player in ipairs(game:GetService('Players'):GetChildren()) do
- if player == Player then continue end
- CreateLabel(player)
- end
- --Add player to list
- game:GetService('Players').PlayerAdded:Connect(function(player)
- CreateLabel(player)
- end)
- --Remove player from list
- game:GetService('Players').PlayerRemoving:Connect(function(player)
- local playerLabel = UI.ScrollingFrame:FindFirstChild(player.Name)
- if playerLabel then
- playerLabel:Destroy()
- end
- end)
- PlayerLabel:Destroy()
- end
- function PartyController:KnitStart()
- local Player = game:GetService('Players').LocalPlayer
- local UI = Player.PlayerGui:WaitForChild('ScreenGui').UI
- local AlertUI = UI.Parent.Alert
- local PartyService = Knit.GetService('PartyService')
- UI.MiscButton.Activated:Connect(function(inputObject: InputObject)
- if UI.MiscButton.Text == 'Create Party' and CurrentParty == nil then
- CurrentParty = PartyService:CreateParty(Player)
- UI.PartyLabel.Text = 'Party: ' .. CurrentParty.Captain.Name
- UI.MiscButton.Text = 'Invite'
- elseif UI.MiscButton.Text == 'Invite' and CurrentSelection and CurrentParty.Player == nil then
- PartyService:InvitePlayer(CurrentParty, CurrentSelection)
- CurrentParty.Player = CurrentSelection
- end
- end)
- UI.LeaveButton.Activated:Connect(function(inputObject: InputObject)
- if CurrentParty and CurrentParty.Captain == Player then
- PartyService:DisbandParty()
- CurrentParty = nil
- UI.PartyLabel.Text = 'Party: None'
- UI.MiscButton.Text = 'Create Party'
- end
- if PartyService:LeaveParty() then
- CurrentParty = nil
- UI.PartyLabel.Text = 'Party: None'
- UI.MiscButton.Text = 'Create Party'
- end
- end)
- PartyService.Invite:Connect(function(captain)
- AlertUI.Alert.Text = 'ALERT: INVITE FROM CAPTAIN : ' .. captain.Name .. ' JOIN?'
- AlertUI.JoinButton.Activated:Connect(function()
- CurrentParty = PartyService:JoinParty(captain)
- UI.PartyLabel.Text = 'Party: ' .. CurrentParty.Captain.Name
- AlertUI.Visible = false
- end)
- AlertUI.LeaveButton.Activated:Connect(function()
- PartyService:RejectInvite()
- AlertUI.Visible = false
- end)
- AlertUI.Visible = true
- end)
- PartyService.Leave:Connect(function()
- CurrentParty = nil
- UI.PartyLabel.Text = 'Party: None'
- UI.MiscButton.Text = 'Create Party'
- end)
- end
- return PartyController
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement