Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Create a gui that show the current players outfit wearring?

Asked by 1 year ago

Hey guys I have this script:

game.Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:FindFirstChild("Humanoid")

    while wait(5) do
        local id = math.random(1,1000000000)
        local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(id)

        humanoid:ApplyDescription(newHumanoidDescription)
    end
end)

and I whant a script that show the name of the player currently wearing (in a gui) but Idk how can I make that, thanks in advance and have a nice day!

3 answers

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

You can use Players:GetNameFromUserIdAsync() to get the username from a user id (only if used id belongs to a real roblox account).

local Players = game:GetService("Players")

local function getRandomPlayer()
    local userId = math.random(1, 2000000000)
    local success, userName = pcall(Players.GetNameFromUserIdAsync, Players, userId)

    if success then -- if userId came from a real player
        return userName, userId
    else
        return getRandomPlayer() -- if userId doesn't exist, it will try again
    end
end

Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:FindFirstChildOfClass("Humanoid")

    while true do
        local name, id = getRandomPlayer()
        local success, newHumanoidDescription
        repeat
            success, newHumanoidDescription = pcall(Players.GetHumanoidDescriptionFromUserId, Players, id)
        until success and newHumanoidDescription

        humanoid:ApplyDescription(newHumanoidDescription)
        -- it's up to you on what you will do to the "name" variable
        -- if you don't have a gui, then create your own
        task.wait(5)
    end
end)
0
TYY! wDaerkfeX 37 — 1y
0
yw <3 T3_MasterGamer 2189 — 1y
Ad
Log in to vote
1
Answered by 1 year ago

add a ViewportFrame, and do this.

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
charclone = character:Clone(game.Players.PlayerGui.ScreenGui.ViewPortFrame)
charclone.HumanoidRootPart.Position = Vector3.new(0, 0, -5)
end)
end)
0
Hey! Ty for your answer ! It seems its dont work... wDaerkfeX 37 — 1y
0
would you be able to email me a template of what you are trying to do so I can solve it? bittyboy1234 91 — 1y
Log in to vote
0
Answered by 1 year ago

you may find thi interesting:

https://create.roblox.com/docs/reference/engine/classes/Players#GetUserThumbnailAsync

Answer this question