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 :

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

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
local random = {
    7074786;
    7074764;
    7699174;
    144075659
}

local Picked = math.random(1,#random)

script.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.

random = {"7074786", "7074764", "7699174" ,"144075659"} — create an array with {} to store ids
script.Parent.Texture = "rbxassetid://"..random[math.random(#random)]

—first, attach rbxassetid:// with (..)
—access the array with []
—get something random with math.random() by putting it inside [], #random gets the number of items in the array

Answer this question