appear = {"http://www.roblox.com/Asset/CharacterFetch.ashx?userId=23749623","http://www.roblox.com/Asset/CharacterFetch.ashx?userId=17199995","http://www.roblox.com/Asset/CharacterFetch.ashx?userId=56449"} game.Players.PlayerAdded:connect(function(Player) local set = appear[math.random(3)] Player.CharacterAppearance = set end)
Hello there, yesterday I tried to work on a script that I was trying to make, what this script does is that when a player joins it randomizes his appearance, unfortunately this script isn't working correctly, I hosted a test server with 5 players and four changed to the same appearance and only one changed to a different appearance, can somebody please tell me whats wrong?
I believe you got that random wrong. You want to choose a random key from the table. The code below should work.
appear = {"http://www.roblox.com/Asset/CharacterFetch.ashx?userId=23749623","http://www.roblox.com/Asset/CharacterFetch.ashx?userId=17199995","http://www.roblox.com/Asset/CharacterFetch.ashx?userId=56449"} game.Players.PlayerAdded:connect(function(Player) local set = appear[math.random(1,#appear)] Player.CharacterAppearance = set end)
Don't forget to accept this as the answer!