I am essentially scripting a drop-down screen that hangs from a roof.

Collapsed Data: Position: -37.907, 29.45, -175.686 Size: 46.2, 0.1, 0.514

Expanded Data: Position: -37.907, 20.55, -175.686 Size: 46.2, 22.1, 0.514

Below is my thought process. I've tried using various for loops, but I have run into the issue of the part expanding in both directions, whereas I only need it expanding down and back up. The button referenced is a GUI button that acts as a toggle.

--[[
	
	Coded by: wattleman
	Date: 09/10/2018
	
	Purpose: To lower/raise the screen (change the size).
	
--]]

debounce = false
print (debounce)
if(not debounce) then
	debounce = true
	--Variables	
	screen = game.Workspace.SlidingScreen.Screen
	button = script.Parent
	
	--Functions
	
	function switch()
		
		if screen.Size == Vector3.new(46.2, 22.1, 0.514) then -- Checks if the screen is lowered, else, lower the screen.
			slideUp()
		else
			slideDown()
		end

	end
	
	function slideUp()
		
		--Raise the screen.
		
		button.Style = "RobloxRoundButton"
	end
	
	function slideDown()
		
		--Lower the screen.
		
		button.Style = "RobloxRoundDropdownButton"
	end


	--Final
	debounce = false
end


	--Trigger
script.Parent.MouseButton1Click:Connect(switch)

5 comments

0

You could use https://www.robloxdev.com/api-reference/function/BasePart/Resize but it only works for integer amounts

0

Due to floating point imprecision the decimals may not be the exact same as your script.

0

Changing it by .1 isn't going to bother me. I can make them integers.

0

Are the other two values going to matter, or just the one that is changing?

0

Also, can I get a partial example?