local player = game.Players.LocalPlayer
local gui = script.Parent
local Open = false

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.R then
		if (Open == false) then
			print("Open is False!")
			for i = 1,0,-0.1 do
				gui.BackgroundTransparency = i
				wait()
			end
			Open = true
			print("Open is now True!")
		elseif (Open == true) then
			print("Open is now True!")
			for k = 0,1,0.1 do
				gui.BackgroundTransparency = k
				wait()
			end
			Open = false
			print("Open is False!")
		end
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

2 comments

0

for i and k doesnt have a cooldown everytime the value increases so it instantaneously goes to 1. Consider placing a wait() below each “gui.BackgroundTransprency = yada-yada”.

0

I put a print at the first part of the script where it detects if Open is indeed false, and it worked there, but the other part of the script failed and didn't print anything