Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local highlight = Instance.new("Highlight")
- highlight.FillColor = Color3.fromRGB(255, 0, 0) -- Red color
- highlight.FillTransparency = 0.5
- highlight.OutlineTransparency = 1 -- Hide outline
- local currentGui
- local function onHover()
- local target = mouse.Target
- if target and target.Parent:FindFirstChild("Humanoid") then
- highlight.Adornee = target.Parent
- highlight.Parent = target.Parent
- else
- highlight.Parent = nil
- end
- end
- local function clearPreviousGui()
- if currentGui then
- currentGui:Destroy()
- currentGui = nil
- end
- end
- local function createInventoryGui(clickedPlayer)
- clearPreviousGui()
- local screenGui = Instance.new("ScreenGui", player.PlayerGui)
- currentGui = screenGui
- local frame = Instance.new("Frame", screenGui)
- frame.Size = UDim2.new(0.3, 0, 0.5, 0)
- frame.Position = UDim2.new(0.35, 0, 0.25, 0)
- frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- frame.BackgroundTransparency = 0.5
- local layout = Instance.new("UIListLayout", frame)
- layout.Padding = UDim.new(0, 5)
- local inventoryLabel = Instance.new("TextLabel", frame)
- inventoryLabel.Size = UDim2.new(1, 0, 0, 30)
- inventoryLabel.Text = clickedPlayer.Name .. "'s Inventory"
- inventoryLabel.BackgroundTransparency = 1
- inventoryLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- inventoryLabel.TextScaled = true
- local inventory = clickedPlayer:FindFirstChild("Backpack")
- if inventory then
- for _, item in pairs(inventory:GetChildren()) do
- local itemLabel = Instance.new("TextLabel", frame)
- itemLabel.Size = UDim2.new(1, 0, 0, 30)
- itemLabel.Text = item.Name
- itemLabel.BackgroundTransparency = 1
- itemLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- itemLabel.TextScaled = true
- end
- else
- local noItemsLabel = Instance.new("TextLabel", frame)
- noItemsLabel.Size = UDim2.new(1, 0, 0, 30)
- noItemsLabel.Text = "No items found."
- noItemsLabel.BackgroundTransparency = 1
- noItemsLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- noItemsLabel.TextScaled = true
- end
- end
- local function onClick()
- local target = mouse.Target
- if target and target.Parent:FindFirstChild("Humanoid") then
- local clickedPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if clickedPlayer then
- createInventoryGui(clickedPlayer)
- end
- end
- end
- mouse.Move:Connect(onHover)
- mouse.Button1Down:Connect(onClick)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement