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!
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)
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)
you may find thi interesting:
https://create.roblox.com/docs/reference/engine/classes/Players#GetUserThumbnailAsync