Trying to make the cloud transition smoother. Nothing happens

I have a problem.

I want to create a smooth transition when the cover in clouds changes. Nothing happens.

The 20 there means how much cover I want. The 20 is divided by 100, so the number is 0.2.

NOTE:

  • The previous script without the transition worked.
  • The script is in Script Server-sided.
while true do
	local clouds = math.random(0, 100)
	print(clouds)
	if clouds >= script.Parent.Cover then
		for i = 1, clouds-script.Parent.Cover do
			wait(0.4)
			script.Parent.Cover += 1/100
		end
	else
		for i = 1, clouds+script.Parent.Cover do
			wait(0.4)
			script.Parent.Cover -= 1/100
		end
	end
	wait(60)
end
2 Likes

You’re trying to divide by a 100 on the increment / decrement, which would lead to a very small transition (0.01). Whether this will even be noticed depends on how the ‘Cover’ property of the parent of the script is used.

Also, just noticed, in your loops, your condition i = 1, clouds-script.Parent.Cover or i = 1, clouds+script.Parent.Cover, would lead to error if the newly generated value of ‘clouds’ is lesser than the current ‘Cover’ value of the script’s parent (for the first loop) and vice-versa (for the second loop).

Here’s a revised script for ya bro:

while true do
    local clouds = math.random(0, 100)/100
    print(clouds)
    if clouds >= script.Parent.Cover.Value then
        for i = script.Parent.Cover.Value, clouds, 0.01 do
            wait(0.4)
            script.Parent.Cover.Value = i
        end
    else
        for i = script.Parent.Cover.Value, clouds, -0.01 do
            wait(0.4)
            script.Parent.Cover.Value = i
        end
    end
    wait(60)
end

Remember to convert script.Parent.Cover to script.Parent.Cover.Value as ‘Cover’ is likely a NumberValue, didnt quite get that tbh. You may also need to adjust the random number generation or assignment to ‘Cover’ based on exactly what those ranges should be.

That is what I am trying to do. Very small transition, so you will not get jumpscared by the clouds appearing from thin air at the speed of light.


Also, nothing happens.

It seems like I’ve figured it out. I can suggest another revision of the script:

while true do
    local clouds = math.random(0, 100)
    print(clouds)
    if clouds >= script.Parent.Cover then
        for i = 1, ((clouds-script.Parent.Cover)*100) do
            wait(0.4)
            script.Parent.Cover = script.Parent.Cover + 0.01
        end
    else
        for i = 1, ((script.Parent.Cover-clouds)*100) do
            wait(0.4)
            script.Parent.Cover = script.Parent.Cover - 0.01
        end
    end
    wait(60)
end

Nothing Happened.

Appologies for that, can you try this?

while true do
    local clouds = math.random(0, 100) / 100
    local currentCover = script.Parent.Cover
    local step = 0.01
    local delay = 0.4

    if clouds > currentCover then
        -- Increase cover
        while script.Parent.Cover < clouds do
            script.Parent.Cover = math.min(script.Parent.Cover + step, clouds)
            wait(delay)
        end
    elseif clouds < currentCover then
        -- Decrease cover
        while script.Parent.Cover > clouds do
            script.Parent.Cover = math.max(script.Parent.Cover - step, clouds)
            wait(delay)
        end
    end

    wait(60)
end
1 Like

That did help. Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.