i have a barrier, and I want to decrease the transparency by 0.1 until it is 0 so that its visible, by using a for loop. I also want it to wait 5 seconds before every 0.1 reduction. However it keeps going to the statement barrier 1 is completed, but its not even visible.
Barrier1 = game.Workspace.Barrier1
Barrier1.Transparency = 1
Barrier1.CanCollide = false
Barrier1.Anchored = true
cost = 50
script.Parent.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.leaderstats.Cash.Value >= cost then
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - cost
Barrier1.Anchored = true
local BarrierTransparency = game.Workspace.Barrier1.Transparency
for BarrierTransparency=1, 0, -0.1 do
if BarrierTransparency == 0 then
Barrier1.CanCollide = true
Barrier1.Transparency = 0
end
end
print("Your barrier has been completed")
else
print("Not enough cash")
end
end)

2 comments
Everything seemed to work fine excpet the Barrier1.CanCollide = true. It seems that it doesnt apply after the object isn't transparent.
@Awesomewebm I also put a print statement saying "Past wait time" after the wait, and in the output you can just see that that number next to the statement is increasing infinitly.