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

How do I fix this never ending transparency modification script?

Asked by 8 years ago
Edited 8 years ago
1if game.workspace.Baseplate.Transparency = 0
2    add 0.1                                                                         <- The part where it adds .1 to the 0
3end
4 
5if game.workspace.Baseplate.Transparency = 1.0 then
6    game.workspace.Baseplate.Transparency = 0           
7end

It is for some reason not working and output is claiming it's near the first =

if game.workspace.Baseplate.Transparency = 0 add 0.1 <- The part where it adds .1 to the 0 end

if game.workspace.Baseplate.Transparency = 1.0 then game.workspace.Baseplate.Transparency = 0
end

How do I fix this.

4 answers

Log in to vote
1
Answered by 8 years ago
01while wait() do
02if game.Workspace.Baseplate.Transparency < 1 then
03    game.Workspace.Baseplate.Transparency = game.Workspace.Baseplate.Transparency + .1
04end
05 
06if game.Workspace.Baseplate.Transparency == 1.0 then
07    game.Workspace.Baseplate.Transparency = 0           
08end
09end
10--Fixed script if you wanna skip explanation

That other answer didn't tell you anything.

Here is what was wrong

You were using game.workspace instead of game.Workspace Lua is case-sensitive so you have to have the correct name!

You were trying to execute Add (?) I assume you were trying to add to the transparency, so yeah.

You were also using = . to compare, you have to say '=='

You forgot the then after the first if statement, so there's that. You were also comparing to see if it was at 0, which if it was it would never fire any of the if statements.

So I set that to be while it's under 1 (last update it'll be .9(lower) + .1)

And finally, you forgot a loop. It'd check once and never fire again. If this doesn't work, please tell me.

Ad
Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
8 years ago

Use == to compare things.

if game.workspace.Baseplate.Transparency == 1.0 then

0
You missed a lot of the issues. fireboltofdeathalt 118 — 8y
Log in to vote
0
Answered by 8 years ago

Don't worry, I'm a beginner and I tried using conditional statement

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago
1if game.workspace.Baseplate.Transparency = 0
2    add 0.1                                                                         <- The part where it adds .1 to the 0
3end
4 
5if game.workspace.Baseplate.Transparency = 1.0 then
6    game.workspace.Baseplate.Transparency = 0           
7end

Wheeze...

Okay, let's start down with the basics.

01-- || Services ||
02local Workspace = game:GetService("Workspace") -- Always do that it's a good habit.
03 
04-- || Learn Conditional Statements ||
05while wait() do
06while Workspace.Baseplate.Transparency < 1 do
07Workspace.Baseplate.Transparency = Workspace.Baseplate.Transparency + 0.1 -- You tried to call ADD when that doesn't exist. You -Could- make a function called add, but that's a waste of time.
08wait() end
09while Workspace.Baseplate.Transparency => 1 do
10Workspace.Baseplate.Transparency = 0
11wait() end
12end
13 
14-- Yes, I made this very sloppily intentionally.

Let's say you made a function called Add.

01local function Add(Value, Number)
02Value = Value + Number
03end
04 
05 
06while wait() do
07while Workspace.Baseplate.Transparency < 1 do
08Add(Workspace.Baseplate.Transparency, 0.1) -- There.
09wait() end
10while Workspace.Baseplate.Transparency => 1 do
11Add(Workspace.Baseplate.Transparency, -1) -- There again. :P
12wait() end
13end

** Anyways, done being rude, time for an actual answer.**

Okay, so you need to understand something called Conditional Statements, you probably learned these in Mathematics. (Unless you sleep in that class. Cough)

Conditional States are as followed:

(Greater Than) < (Less Than) = (Equal To (In Math... In Programming it's for setting a value or something.)) >= (Greater Than or Equal To) <= (Less Than or Equal To) == (Equal To for If Than Statements.) ~= (Not Equal To)

You also don't know how to call the Math stuff in rbx.lua. Which is fine! Programming takes practice, lemme show you the symbols:

(+) is Adding

(-) is Subtracting

(*) is Multiplying

(/) is Dividing

(%) is Dividing with a Remainder (Basically)

If you have any other questions. Just let me know. :P

Answer this question