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

How can I randomize a players appearance with a call-able function?

Hello,

I am trying to make a function that randomizes players appearance when called. How would I go about doing this, my first thought would to use randomized player.userId's in the place of this:

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=math.random(16, 145599999" 
end)

If your wondering where I got my math.random numbers, I recently calculated the Roblox population as of 7/22/16 around 11 there were 145599999 players registered to Roblox. anything below 16 could give an error because there are missing player slots for 6,7,8,9,10 etc...

I got the above function to work, but when I turn it into a callable function, and try to call it, it doesn't work. I also noticed that the above function only works when the player joins the game and not if they respawn.

So how can I randomize a character's appearance with a callable function. We don't need to use the method above, if there is an easier or more clean way I'd rather go with that. So whats going on, how can I do this?

Thanks in advance,

--Deka

1 answer

✓ Accepted answer

Well, the best way to do this is:

local appearance = math.random(16, 145599999)

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAppearance = "http://assetgame.roblox.com/Asset/CharacterFetch.ashx?userId="..appearance.."&placeId=YOURPLACEID"
end)

I dont really recommend doing this though, unless you really want to. Cause most id's are the "newest player" id.

4 comments

0

Do you have a better way?

0

Not exactly, I just dont think you should be math.randoming the id's.

0

Also, this sint what I had in mind, I wanted to call the function without using players added

0

Well when did you want to call the function?

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