Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Create a gui that show the current players outfit wearring?

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

✓ Accepted answer

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)

2 comments

0

TYY!

0

yw <3

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)

2 comments

0

Hey! Ty for your answer ! It seems its dont work...

0

would you be able to email me a template of what you are trying to do so I can solve it? bittyyt23@gmail.com

This discussion is preserved as it was. New answers, comments, and votes are closed.