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

how to make a brick transparency 1 or 0 onclick?

Asked by 10 years ago

I am attempting to make a OnClick script that when you click on the brick it goes to transparency=1 or transparency=0

4 answers

Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
10 years ago

Here, put this script inside the brick:

script.Parent.ClickDetector.MouseClick:connect(function()
    if script.Parent.Transparency == 0 then
        script.Parent.Transparency = 1
    elseif script.Parent.Transparency == 1 then
        script.Parent.Transparency = 0
    end
end)

Ad
Log in to vote
-1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
local brick = script.Parent
brick.ClickDetector.MouseClick:connect(function()
    brick.Transparency = brick.Transparency == 0 and 1 or 0
end)
Log in to vote
-1
Answered by 10 years ago
-- PUT THIS SCRIPT IN THE BRICK
brick = script.Parent

function TurnVisible()
    if brick.Transparency == 1 then
        brick.Transparency = 0
        -- Add anything else you want, like changing the name, color etc.
    elseif brick.Transparency == 0 then
        brick.Transparency = 1
        -- Add anything else you want, like changing the name, color etc.
    end
end

brick.MouseButton1Down:connect(TurnVisible)

--if Line 14 doesn't work all the time, do this and remove the --[[ and ]]

--[[ while true do
brick.MouseButton1Down:connect(TurnVisible)
wait()
end ]]
Log in to vote
-3
Answered by 10 years ago
script.Parent.ClickDetector.MouseClick:connect(function()
 if Part.Transperancy ==  0 do
wait()
script.Parent.Transperancy = 1
wait(1)
script.Parent.Transperancy = 0
end)
-- Add a ClickDetector in the brick and this script.
0
There gave you both codes when a player Clicks it turns invisible wait 1-2 seconds and it will return Visible. digitalzer3 123 — 10y

Answer this question