-- Service References local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer -- Create Main GUI (Key: Set ResetOnSpawn to false to prevent disappearance on respawn) local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "PlayerInventoryViewer" ScreenGui.Parent = LocalPlayer.PlayerGui ScreenGui.ResetOnSpawn = false -- Core property: Do not reset GUI on respawn ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling -- Ensure proper layer display -- Main Frame (Draggable) local MainFrame = Instance.new("Frame") MainFrame.Name = "MainFrame" MainFrame.Size = UDim2.new(0, 350, 0, 400) MainFrame.Position = UDim2.new(0.1, 0, 0.1, 0) MainFrame.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1) MainFrame.BackgroundTransparency = 0.2 MainFrame.BorderColor3 = Color3.new(0.8, 0.8, 0.8) MainFrame.BorderSizePixel = 2 MainFrame.ClipsDescendants = true MainFrame.Parent = ScreenGui -- Title Bar local TitleBar = Instance.new("Frame") TitleBar.Name = "TitleBar" TitleBar.Size = UDim2.new(1, 0, 0, 30) TitleBar.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) TitleBar.Parent = MainFrame local TitleLabel = Instance.new("TextLabel") TitleLabel.Name = "TitleLabel" TitleLabel.Size = UDim2.new(1, 0, 1, 0) TitleLabel.BackgroundTransparency = 1 TitleLabel.Text = "Player Inventory Viewer | Refreshes every second | Persists on death" TitleLabel.TextColor3 = Color3.new(1, 1, 1) TitleLabel.Font = Enum.Font.SourceSansBold TitleLabel.TextSize = 16 TitleLabel.Parent = TitleBar -- Scroll Container local ScrollFrame = Instance.new("ScrollingFrame") ScrollFrame.Name = "ScrollFrame" ScrollFrame.Size = UDim2.new(1, -10, 1, -35) ScrollFrame.Position = UDim2.new(0, 5, 0, 35) ScrollFrame.BackgroundTransparency = 1 ScrollFrame.BorderSizePixel = 0 ScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0) ScrollFrame.ScrollBarThickness = 5 ScrollFrame.Parent = MainFrame local UIListLayout = Instance.new("UIListLayout") UIListLayout.FillDirection = Enum.FillDirection.Vertical UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Top UIListLayout.Padding = UDim.new(0, 5) UIListLayout.Parent = ScrollFrame -- Drag Function Implementation local isDragging = false local dragStartPos = nil local frameStartPos = nil TitleBar.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then isDragging = true dragStartPos = input.Position frameStartPos = MainFrame.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then isDragging = false end end) end end) UserInputService.InputChanged:Connect(function(input) if isDragging and input.UserInputType == Enum.UserInputType.MouseMovement then local delta = input.Position - dragStartPos MainFrame.Position = UDim2.new( frameStartPos.X.Scale, frameStartPos.X.Offset + delta.X, frameStartPos.Y.Scale, frameStartPos.Y.Offset + delta.Y ) end end) -- GUI Persistence Protection: Automatically rebuild if GUI is accidentally removed local function ensureGUIPersists() if not LocalPlayer.PlayerGui:FindFirstChild("PlayerInventoryViewer") then ScreenGui.Parent = LocalPlayer.PlayerGui end if not ScreenGui:FindFirstChild("MainFrame") then MainFrame.Parent = ScreenGui end end -- Listen for player respawn event to ensure GUI is not lost LocalPlayer.CharacterAdded:Connect(function() ensureGUIPersists() end) -- Refresh Player Info Function local function refreshPlayerInfo() ensureGUIPersists() -- Check if GUI exists before each refresh -- Clear old content for _, child in ipairs(ScrollFrame:GetChildren()) do if child:IsA("Frame") then child:Destroy() end end -- Iterate through all players for _, player in ipairs(Players:GetPlayers()) do if player ~= LocalPlayer then -- Create player info frame local PlayerFrame = Instance.new("Frame") PlayerFrame.Size = UDim2.new(1, -10, 0, 100) PlayerFrame.BackgroundColor3 = Color3.new(0.15, 0.15, 0.15) PlayerFrame.BackgroundTransparency = 0.2 PlayerFrame.BorderColor3 = Color3.new(0.6, 0.6, 0.6) PlayerFrame.BorderSizePixel = 1 PlayerFrame.Parent = ScrollFrame -- Player Name local PlayerNameLabel = Instance.new("TextLabel") PlayerNameLabel.Size = UDim2.new(1, -10, 0, 20) PlayerNameLabel.Position = UDim2.new(0, 5, 0, 5) PlayerNameLabel.BackgroundTransparency = 1 PlayerNameLabel.Text = "Player: " .. player.Name PlayerNameLabel.TextColor3 = Color3.new(0.4, 0.9, 1) PlayerNameLabel.Font = Enum.Font.SourceSansBold PlayerNameLabel.TextSize = 14 PlayerNameLabel.Parent = PlayerFrame -- Held Item local heldTool = "None" if player.Character then local tool = player.Character:FindFirstChildOfClass("Tool") if tool then heldTool = tool.Name end end local HeldItemLabel = Instance.new("TextLabel") HeldItemLabel.Size = UDim2.new(1, -10, 0, 20) HeldItemLabel.Position = UDim2.new(0, 5, 0, 30) HeldItemLabel.BackgroundTransparency = 1 HeldItemLabel.Text = "Held Item: " .. heldTool HeldItemLabel.TextColor3 = Color3.new(0.9, 0.6, 0.3) HeldItemLabel.Font = Enum.Font.SourceSans HeldItemLabel.TextSize = 13 HeldItemLabel.Parent = PlayerFrame -- Backpack Items local backpackItems = "None" if player.Backpack then local items = player.Backpack:GetChildren() if #items > 0 then local itemNames = {} for _, item in ipairs(items) do table.insert(itemNames, item.Name) end backpackItems = table.concat(itemNames, ", ") end end local BackpackLabel = Instance.new("TextLabel") BackpackLabel.Size = UDim2.new(1, -10, 0, 40) BackpackLabel.Position = UDim2.new(0, 5, 0, 55) BackpackLabel.BackgroundTransparency = 1 BackpackLabel.Text = "Backpack Items: " .. backpackItems BackpackLabel.TextColor3 = Color3.new(0.5, 0.9, 0.5) BackpackLabel.Font = Enum.Font.SourceSans BackpackLabel.TextSize = 12 BackpackLabel.TextWrapped = true BackpackLabel.Parent = PlayerFrame end end -- Update scroll area size UIListLayout:ApplyLayout() ScrollFrame.CanvasSize = UDim2.new(0, 0, 0, UIListLayout.AbsoluteContentSize.Y) end -- Refresh every second while task.wait(1) do pcall(refreshPlayerInfo) -- Prevent script stop due to errors end