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

Simple Touch Event won't work?

Asked by
Scerzy 85
10 years ago

Brick = game.Workspace.Brick

function Spleef()

brick.Transparency = 0.1

wait(.1)

brick.Transparency = 0.2 0 wait(.1)

brick.Transparency = 0.3

wait(.1)

brick.Transparency = 0.4

wait(.1)

brick.Transparency = 0.5

wait(.1)

brick.Transparency = 0.6

wait(.1)

brick.Transparency = 0.7

wait(.1)

brick.Transparency = 0.8

wait(.1)

brick.Transparency = 0.9

wait(.1)

brick.Transparency = 1.0

end

Brick.Touched:connect(Spleef)

This should gradually make the part fade, correct? It would go from transparency 0-1 in 1 second when someone touches it. For some reason it doesn't. Does anyone see a problem?

2 answers

Log in to vote
0
Answered by 10 years ago

When you set the transparency, make sure brick is "Brick", as you defined it! Capital b. Reference a variable as it's defined. #1 law of variables.

0
Oh wow. Duhh. I'm an idiot Scerzy 85 — 10y
Ad
Log in to vote
0
Answered by
Vividex 162
10 years ago

Lots of problems in this script, and you can make it less complex, try this:

brick = game.Workspace.Brick

function Spleef()
    for i = .1, 1, 0.1 do
    brick.Transparency = i
end

script.Parent.Touched:connect(Spleef)

Remember to put this inside each Brick

Answer this question