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

Why not work?

Asked by
igric 29
10 years ago

local brick = game.Workspace.DisappearingBrick

function onTouch(part) wait(0.1) Part.Transparency = 0.1 wait(0.1) Part.Transparency = 0.2 wait(0.1) Part.Transparency = 0.3 wait(0.1) Part.Transparency = 0.4 wait(0.1) Part.Transparency = 0.5 wait(0.1) Part.Transparency = 0.6 wait(0.1) Part.Transparency = 0.7 wait(0.1) Part.Transparency = 0.8 wait(0.1) Part.Transparency = 0.9 wait(0.1) Part.Transparency = 1 end

brick.Touched:connect(onTouch)

2 answers

Log in to vote
1
Answered by
Nifer2 174
10 years ago
01local brick = game.Workspace.DisappearingBrick
02 
03function onTouch(part)
04    brick.Transparency = 0 -- This is the starting transparency.
05    for i = 1, 10 do -- Runs the code below 10 times. Ends up with 1 Transparency.
06        wait(0.1)
07        part.Transparency = part.Transparency + 0.1 -- Every 10 milliseconds, it becomes 10% more transparent.
08    end
09end
10 
11brick.Touched:connect(onTouch)

I think this should work for you.

Ad
Log in to vote
-1
Answered by
iLegitus 130
10 years ago

Here is a better code : (script must be inside part)

01script.Parent:Touched:connect(function(hit)
02wait(0.03)
03script.Parent.Transparency = 0.1
04script.Parent.Transparency = 0.2
05script.Parent.Transparency = 0.3
06script.Parent.Transparency = 0.4
07script.Parent.Transparency = 0.5
08script.Parent.Transparency = 0.6
09script.Parent.Transparency = 0.7
10script.Parent.Transparency = 0.8
11script.Parent.Transparency = 0.9
12script.Parent.Transparency = 0
13print("iLegimate Sucessfully helped you.")

Answer this question