I was trying to make button that stops the weird flickering of the Transparency when a Character touches it with Touched event,but it didn't work out because the Coroutine doesn't start or resume,why? And is there another way to stop the weird flickering of the Transparency? If so please tell me.
local Part = script.Parent
-----------------------------
ChangeTransparency = coroutine.create(function()--Checks if Transparency is 0.5 if it is then turn it to 0
if Part.Transparency == 0.5
then
Part.Transparency = 0
end
end)
-----------------------------
coroutine.resume(ChangeTransparency)--Changes the part back to normal just incase it hasn't
Part.Touched:connect(function(TouchedPart)
Part.Transparency = 0.5
print("I've been touched")
coroutine.yield(ChangeTransparency)--Stops coroutine
end)
-----------------------------
Part.TouchEnded:connect(function()
coroutine.resume(ChangeTransparency)--Changes the part back to normal
end)

1 comment
Within the ChangeTransparency function, you'll need to re-define the variables as Lua is basically running it as its own script. An idea for the weird flickering is to use debounce. http://wiki.roblox.com/index.php?title=Debounce#Real_world