Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I'm new to scripting but I want some help on the If Statement that I have?

Okay so I know some parts about if statements but how do you do it when for example

A part turns invisible it prints a message like "This part is Transparent" but I want it to have it that it randomises it so when I press run it can either be transparent or not transparent.

Above this line of code I want to have a code that randomises the chances of the part being transparent. The part is called "Transparent". I already started the code. Btw I don't want this post to sound like I command you to do it, I just want some advice on how to do such a thing.

if game.Workspace.Transparent.Transparency == 1 then
	print("This part is transparent!")
end

1 answer

✓ Accepted answer

Hello, i've been thinking and i'll explain how i would do it. So i'd just put a random number generator for the transparency as it's 1 and 0 so what you should do is that , if you don't understand here's an example:

game.Workspace.Transparent.Transparency == math.random(0,1)

So this will generate a number between 1 and 0 of course that means it can be only 1 and 0 but you can change it to anything you'd like example as "0,50" will generate numbers between 0 and 50 so the first number that's "0" is the minimum of the numbers you want generated, the second number the "1" is the maximum of numbers you'd like to get generated if you don't understand my explaining feel free to check out roblox's source because my english is bad

Roblox's source

or try

Lua's source

3 comments

0

Thank's a lot!

1

Okay it works, I should of thought of this, And btw your English is very good!

0

Glad to help :D

This discussion is preserved as it was. New answers, comments, and votes are closed.