How can I make something gain/lose transparency depending on my vehicle's Throttle

I am trying to make a pirate ship where when the ship is moving, the Sails would gradually appear while the RetractedSails would gradually disappear, and vice versa when the ship stops moving. For some reason, the sails and retractedsails aren’t appearing at all when my ship starts to move. Any ideas on how I can fix this script

local Sails = script.Parent.Parent.Sails
local RetractedSails = script.Parent.Parent.RetractedSails

while true do
	wait()
	

	
	if script.Parent.Throttle == 1 then repeat
		
			wait(0.001)
			Sails.Transparency = Sails.Transparency - 0.05
			RetractedSails.Transparency = RetractedSails.Transparency + 0.05
	
		until Sails.Transparency == 0 and RetractedSails.Transparency == 1
		
	elseif script.Parent.Throttle == 0 then repeat

			wait(0.001)
			Sails.Transparency = Sails.Transparency + 0.05
			RetractedSails.Transparency = RetractedSails.Transparency - 0.05

		until Sails.Transparency == 1 and RetractedSails.Transparency == 0
	
		
	end
end


I’d start off by printing the transparency of the RetractedSails and Sails to see if there is an issue with it. I’ve come across a bug where doing Example.Transparency = Example.Transparency - 0.05 can go to -0 rather than just a flat 0. I also recommend doing

if script.Parent.Throttle == 1 then 
	for i = 1, 20 do
		wait(0.001)
		Sails.Transparency = Sails.Transparency - 0.05
		RetractedSails.Transparency = RetractedSails.Transparency + 0.05
		if Sails.Transparency < 0 then
			Sails.Transparency = 0
		end
		if RetractedSails.Transparency > 1 then
			RetractedSails.Transparency = 1
		end
	end
elseif script.Parent.Throttle == 0 then 
	for i = 1, 20 do
		wait(0.001)
		Sails.Transparency = Sails.Transparency + 0.05
		RetractedSails.Transparency = RetractedSails.Transparency - 0.05
		if RetractedSails.Transparency < 0 then
			RetractedSails.Transparency = 0
		end
		if Sails.Transparency > 1 then
			Sails.Transparency = 1
		end
	end
end

rather than repeat until. See if this helps, if not let me know if you get any errors.

It works perfectly! Thanks for the help.

I’m glad it works! Good luck with the rest of your project! :slight_smile: