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

This isn't working correctly, help?

Asked by 10 years ago
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?

1 answer

Log in to vote
0
Answered by 10 years ago

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!

0
it's still the same :( biocommand 30 — 10y
0
What's the error? YasuYoshida 171 — 10y
Ad

Answer this question