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

[SOLVED] I want a script that randomly picks a face, Any help ?

Asked by 5 years ago
Edited 5 years ago

Sorry if i'm asking for a script, i'm not used to scripting.

So here is what i want to do. I want a script that randomly picks a face (e.g picks 7074786, 7074764, 7699174 or 144075659.) for a fake person. But i don't know how to make that happen Here is what is think it would be like :

1random = ("7074786, 7074764, 7699174 ,144075659")
2script.parent.texture = ("random")

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
01local random = {
02    7074786;
03    7074764;
04    7699174;
05    144075659
06}
07 
08local Picked = math.random(1,#random)
09 
10script.Parent.Texture = "http://www.roblox.com/asset/?id="..random[Picked]
Ad
Log in to vote
0
Answered by 5 years ago

(Your guess is pretty good so it’s not asking for a script, don’t worry)

That code is almost complete, but to pick something random, we use the function math.random.

We also need to add rbxassetid:// to the front of the string as that’s what a decal's Texture property takes.

1random = {"7074786", "7074764", "7699174" ,"144075659"} — create an array with {} to store ids
2script.Parent.Texture = "rbxassetid://"..random[math.random(#random)]
3 
4—first, attach rbxassetid:// with (..)
5—access the array with []
6—get something random with math.random() by putting it inside [], #random gets the number of items in the array

Answer this question