I am trying to make a Part become completely transparent, over the course of 60 seconds. Wait 7 seconds, and then repeat continuously. Here's what I've Tried:
1) Insert NumberValue into Part (Value =0)
2) Inserted Script into part:
01 | local transparency = script.Parent.Transparency |
02 |
03 | while true do |
04 |
05 | script.Parent.Transparency = transparency.Value |
06 |
07 | for i = 1 ,transparency.Value do |
08 |
09 | wait( 1 ) |
10 |
11 | transparency.Value = transparency.Value + 0.01666666 --i/60 |
12 |
13 | script.Parent.Transparency = transparency.Value |
14 |
15 | end |
While testing the game, the part does not become more transparent.
Here's an error code that show up: Workspace.Part.Transparency Script:3: attempt to index local 'transparency' (a number value)
I'm new to scripting and would really appreciate some help/feedback. Thank you!
You're making it more complicated than it has to be. Just do this instead:
01 | while true do |
02 | for i = ( 1 / 60 ), 1 , ( 1 / 60 ) do |
03 | wait( 1 ) |
04 | script.Parent.Transparency = i |
05 | end |
06 | script.Parent.Transparency = 1 --This is to ensure that the transparency gets set equal to 1. |
07 | wait( 7 ) |
08 | script.Parent.Transparency = 0 |
09 | end |
10 |
11 | --[[ |
12 |
13 | i = (1/60) is that starting value, 1 is the ending value, and 1/60 is how much is added to the previous value. |
14 |
15 | I basically set the transparency of the part equal to the variable i. That's all you had to do. |
16 |
17 | ]] -- |
your scipt sets a variable AS the transparency it's only changing your variable.
1 | local tparency = script.Parent |
2 | tparency.Transparency = 1 --THIS WORKS |
3 |
4 | local tparency 2 = script.Parent.Transparency |
5 | tparency 2 = . 5 -- This changes the variable |
also why are you trying to change a nonexisting value you cant have a number in a number ;(transparency.Value does not work) instead do transparency = (number0