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

Transparency = Transparency.Random() .. It's not working :/ ?

Asked by 8 years ago

I tried to make my part transparency Randomly For My Game..

My Script is:

Game.Workspace.Part.Transparency = Transparency.Random()

And ITs not Working :(

3 answers

Log in to vote
0
Answered by 8 years ago

game.workspace.Part.Transparency = math.random(1,10)/10 This will create a random number between one and ten, and then divide that value so that you get either a decimal in the tenth's place or one.

Ad
Log in to vote
3
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

Problem

What is happening is, there is no globally recognized function for Transparency. BrickColor is something unique because it essentially is a function when setting its value (BrickColor.new()). In fact transparency is a float value, meaning it will only take a number between 0 and 1 and display it properly.


Solution

What you can do is use math.random(). If there are no arguments of math.random() then Lua will pick any decimal between 0 and 1 every time.


Final Script

game.Workspace.Part.Transparency = math.random()

Hopefully this answered your question. If so, hit the accept answer button. If you have any questions feel free to comment below.
Log in to vote
0
Answered by 8 years ago

Got It!

while true do
   wait(1)
Game.Workspace.Part.Transparency = math.Random(1,10)/10

end

Answer this question