it takes a while before cancollide is false for whatever reason
and then starts to blink. why?
for i = 1,360 do
local part = Instance.new("Part")
part.Touched:Connect(function()
for i=1,100 do
part.Transparency = part.Transparency + 0.01
wait()
end
print("done")
part.CanCollide = false
wait(2)
part.Transparency = 0
part.CanCollide= true
end)
end
even though it prints"done" it takes a while to set it to cancollide
I think I have an idea, change your for loop to a while loop and add this:
while true do
part.Transparency = part.Transparency + 0.01
if part.Transparency == 1 then
part.CanCollide = false
break
wait()
end
print(“Finished the while loop”)
wait(2)
part.Transparency = 0
part.CanCollide = true
end
end)
Or maybe do what @Neutron_Flow said and use debounce since it might be because its firing the print event multiple times before moving on.
First of all i dont understand why are you creating non parented parts?
for i=1,100 do
part.Transparency = part.Transparency + 0.01
wait()
end
You should take a look at Tween Service instead of a for loop for transparency and use debounce
local Ts = game:GetService("TweenService")
local info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
for i = 1,360 do
local part = Instance.new("Part")
local debounce = false
part.Touched:Connect(function()
if debounce == false then
debounce = true
local TransTween = Ts:Create(part,info,{Transparency = 1})
TransTween:Play()
wait(1)
print("done")
part.CanCollide = false
wait(2)
part.Transparency = 0
part.CanCollide= true
wait(1)
debounce = false
end
end)
end