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)
Try using debounce;
local Part = script.Parent local Debounce = false Part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")and not Debounce then Debounce = true while Debounce == true do wait(0) Part.Transparency = 0.5 if Debounce == false then break end end end end) Part.TouchEnded:connect(function() Debounce = false Part.Transparency = 0 end)
A bit buggy, but it works. Hope this helped!