0% found this document useful (0 votes)
6 views3 pages

Message

This document describes a LocalScript for a Roblox game that creates a customizable player list with volume controls for each player. It includes functionality for showing and hiding the list using the Tab key, as well as dynamically updating player names and volumes based on the Audio API. The script manages the layout and interactions within the GUI, ensuring a smooth user experience.

Uploaded by

dubazz4ikkr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Message

This document describes a LocalScript for a Roblox game that creates a customizable player list with volume controls for each player. It includes functionality for showing and hiding the list using the Tab key, as well as dynamically updating player names and volumes based on the Audio API. The script manages the layout and interactions within the GUI, ensuring a smooth user experience.

Uploaded by

dubazz4ikkr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- Tab-список + пер-игроковая громкость VC (Audio API)

-- LocalScript в StarterPlayerScripts
local Players=game:GetService("Players")
local StarterGui=game:GetService("StarterGui")
local CAS=game:GetService("ContextActionService")
local UIS=game:GetService("UserInputService")
local TS=game:GetService("TweenService")
local LP=Players.LocalPlayer
pcall(function() StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
end)

local gui=Instance.new("ScreenGui"); gui.IgnoreGuiInset=true;


gui.ResetOnSpawn=false; gui.Name="TabListVC";
gui.Parent=LP:WaitForChild("PlayerGui")
local panel=Instance.new("Frame"); panel.AnchorPoint=Vector2.new(1,0);
panel.Position=UDim2.new(1,-12,0,12); panel.Size=UDim2.new(0,340,0,440)
panel.BackgroundColor3=Color3.fromRGB(18,18,22); panel.BackgroundTransparency=.06;
panel.Visible=false; panel.Parent=gui
Instance.new("UICorner",panel).CornerRadius=UDim.new(0,10)

local title=Instance.new("TextLabel"); title.BackgroundTransparency=1;


title.Font=Enum.Font.GothamSemibold; title.TextSize=20
title.TextColor3=Color3.fromRGB(235,235,245);
title.TextXAlignment=Enum.TextXAlignment.Left
title.Size=UDim2.new(1,-20,0,32); title.Position=UDim2.new(0,10,0,10);
title.Text="Игроки"; title.Parent=panel
local sep=Instance.new("Frame"); sep.BackgroundTransparency=.9;
sep.BorderSizePixel=0; sep.Size=UDim2.new(1,-20,0,1);
sep.Position=UDim2.new(0,10,0,46); sep.Parent=panel

local scroll=Instance.new("ScrollingFrame"); scroll.BackgroundTransparency=1;


scroll.ScrollBarThickness=6
scroll.Size=UDim2.new(1,-20,1,-60); scroll.Position=UDim2.new(0,10,0,52);
scroll.CanvasSize=UDim2.new(); scroll.Parent=panel
local layout=Instance.new("UIListLayout",scroll); layout.Padding=UDim.new(0,8);
layout.SortOrder=Enum.SortOrder.LayoutOrder
local pad=Instance.new("UIPadding",scroll); pad.PaddingTop=UDim.new(0,4);
pad.PaddingLeft=UDim.new(0,2); pad.PaddingRight=UDim.new(0,2)

local function mkRow(p,order)


local row=Instance.new("Frame"); row.Name="row_"..p.UserId;
row.LayoutOrder=order; row.Size=UDim2.new(1,0,0,48)
row.BackgroundColor3=Color3.fromRGB(26,26,32); row.Parent=scroll;
Instance.new("UICorner",row).CornerRadius=UDim.new(0,8)

local name=Instance.new("TextLabel"); name.BackgroundTransparency=1;


name.Font=Enum.Font.Gotham; name.TextSize=16
name.TextXAlignment=Enum.TextXAlignment.Left;
name.TextColor3=Color3.fromRGB(230,230,240)
name.Text=((p==LP) and "★ " or "")..((p.DisplayName~=p.Name) and
(p.DisplayName.." (@"..p.Name..")") or p.Name)
name.Size=UDim2.new(1,-110,0,22); name.Position=UDim2.new(0,10,0,6);
name.Parent=row

-- Слайдер громкости 0..3 (по умолч 1.0)


local track=Instance.new("Frame");
track.BackgroundColor3=Color3.fromRGB(40,40,48); track.BorderSizePixel=0
track.Size=UDim2.new(0,92,0,6); track.Position=UDim2.new(1,-100,0,22);
track.Parent=row; Instance.new("UICorner",track).CornerRadius=UDim.new(1,0)
local knob=Instance.new("Frame");
knob.BackgroundColor3=Color3.fromRGB(90,150,255); knob.Size=UDim2.new(0,10,0,10)
knob.Position=UDim2.new(.333, -5, 0, -2); knob.Parent=track;
Instance.new("UICorner",knob).CornerRadius=UDim.new(1,0)
local valLbl=Instance.new("TextLabel"); valLbl.BackgroundTransparency=1;
valLbl.Font=Enum.Font.Gotham; valLbl.TextSize=12
valLbl.TextColor3=Color3.fromRGB(190,195,210);
valLbl.Size=UDim2.new(0,34,0,16); valLbl.Position=UDim2.new(1,-34,0,0);
valLbl.Text="1.0"; valLbl.Parent=row

-- Привязка к Audio API, если доступен AudioDeviceInput у игрока


local function setVolume(v)
valLbl.Text=string.format("%.1f",v)
local adi=p:FindFirstChild("AudioDeviceInput")
if adi and adi:IsA("AudioDeviceInput") then
pcall(function() adi.Volume=v end) -- прямой контроль потока
голоса
end
end
setVolume(1.0)

local dragging=false
local function updateFromX(x)
local gx=track.AbsolutePosition.X; local gw=track.AbsoluteSize.X
local a=math.clamp((x-gx)/gw,0,1); local v=math.round(a*30)/10 -- шаг
0.1, 0..3.0
knob.Position=UDim2.new(a,-5,0,-2); setVolume(v)
end
track.InputBegan:Connect(function(i)
if i.UserInputType==Enum.UserInputType.MouseButton1 then dragging=true;
updateFromX(i.Position.X) end
end)
track.InputEnded:Connect(function(i) if
i.UserInputType==Enum.UserInputType.MouseButton1 then dragging=false end end)
UIS.InputChanged:Connect(function(i) if dragging and
i.UserInputType==Enum.UserInputType.MouseMovement then updateFromX(i.Position.X)
end end)

-- авто-подхват, когда объект AudioDeviceInput появится после join


p.ChildAdded:Connect(function(ch) if ch:IsA("AudioDeviceInput") then
pcall(function() ch.Volume=tonumber(valLbl.Text) or 1 end) end end)

-- изменение имени в рантайме


p:GetPropertyChangedSignal("DisplayName"):Connect(function()
name.Text=((p==LP) and "★ " or "")..((p.DisplayName~=p.Name) and
(p.DisplayName.." (@"..p.Name..")") or p.Name)
end)
return row
end

local function canvas()


scroll.CanvasSize=UDim2.new(0,0,0,layout.AbsoluteContentSize.Y+8) end
layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(canvas)

local function rebuild()


for _,ch in ipairs(scroll:GetChildren()) do if ch:IsA("Frame") then
ch:Destroy() end end
local list=Players:GetPlayers()
table.sort(list,function(a,b) local ta=a.Team and a.Team.Name or ""; local
tb=b.Team and b.Team.Name or ""
if ta==tb then return string.lower(a.DisplayName or
a.Name)<string.lower(b.DisplayName or b.Name) else return ta<tb end end)
for i,p in ipairs(list) do mkRow(p,i) end
title.Text=("Игроки ("..#list..")"); canvas()
end
Players.PlayerAdded:Connect(rebuild); Players.PlayerRemoving:Connect(rebuild);
rebuild()

-- Показ по Tab
local open=false
local function show() if open then return end open=true panel.Visible=true
panel.Position=UDim2.new(1,-12,0,-8)

TS:Create(panel,TweenInfo.new(.12,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{Position=UDim2.new(1,-12,0,12)}):Play() end
local function hide() if not open then return end open=false

TS:Create(panel,TweenInfo.new(.12,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{Position=UDim2.new(1,-12,0,-8)}).Completed:Connect(function() if not open then
panel.Visible=false end end):Play() end
CAS:BindActionAtPriority("ToggleTabList",function(_,s) if
s==Enum.UserInputState.Begin then if UIS:GetFocusedTextBox() then return
Enum.ContextActionResult.Pass end (open and hide() or show()) end return
Enum.ContextActionResult.Sink
end,false,Enum.ContextActionPriority.High.Value,Enum.KeyCode.Tab)
LP.CharacterAdded:Connect(hide)

You might also like