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

How can a randomize a players appearance with a function?

Asked by 7 years ago

Hello, I recently attempted to randomize the players appearance, however it only seems to work if I you the PlayerAdded command. I want to randomize every character's appearance within a table using a function.

In order to make randomization simple I ran multiple tests to see what the population of roblox is, I got values between 16, and 145599999. anything below 16 can give errors because they no longer exist.

So basically this:

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

the above works fine, but for some reason when I try to incorporate it in a function like this:

function randomizecharacter()
for _, player in pairs(game.Players:GetPlayers()) do
    delay(1, function(player)
        player.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..math.random(16, 145599999)
    end)
end
end

It doesn't work at all or give errors.

So how can I randomize players based on a user id value between 16, and 145599999 using a call able function and not only from when the player is added.

Thanks in advance if anyone actually answers this.

1 answer

Log in to vote
0
Answered by 7 years ago

You need to call the function; you have not called it you have only declared it. The first time it worked because the function was called when a player was added. I do not understand why you do not want to do it with player added. If it is you want this to randomly occur in the game do player added but on the second line type ~~~~~~~~~~~~~~~~~ wait(math.random(1,60)) ~~~~~~~~~~~~~~~~~

0
Forgive me for not clearifying, but I do infact know how to call a function... I posted this question here because the function did not work, not because I didn't know how to call it or forgot. What you see above is simply the functions I'd like to call but for somereason they don't work. Sorry for the clearity. Dekadrachm 50 — 7y
Ad

Answer this question