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
9 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
9 years ago
local brick = game.Workspace.DisappearingBrick

function onTouch(part)
    brick.Transparency = 0 -- This is the starting transparency.
    for i = 1, 10 do -- Runs the code below 10 times. Ends up with 1 Transparency.
        wait(0.1)
        part.Transparency = part.Transparency + 0.1 -- Every 10 milliseconds, it becomes 10% more transparent.
    end
end

brick.Touched:connect(onTouch)

I think this should work for you.

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

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

script.Parent:Touched:connect(function(hit)
wait(0.03)
script.Parent.Transparency = 0.1
script.Parent.Transparency = 0.2
script.Parent.Transparency = 0.3
script.Parent.Transparency = 0.4
script.Parent.Transparency = 0.5
script.Parent.Transparency = 0.6
script.Parent.Transparency = 0.7
script.Parent.Transparency = 0.8
script.Parent.Transparency = 0.9
script.Parent.Transparency = 0
print("iLegimate Sucessfully helped you.")

Answer this question