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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
VitroxVox 884 Moderation Voter
4 years ago

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

0
Thank's a lot! menofmen1234 20 — 4y
1
Okay it works, I should of thought of this, And btw your English is very good! menofmen1234 20 — 4y
0
Glad to help :D VitroxVox 884 — 4y
Ad

Answer this question