Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

KeyDown Function is giving no errors but doesn't emit a function?

player = game.Players.LocalPlayer
mouse = player:GetMouse()
gui = script.Parent
Open = false

function PressE(key)
	if (key == "e") then
		if (Open == false) then
			for i = 1,0,-0.1 do
				gui.BackgroundTransparency = i
			end
			Open = true
		elseif (Open == true) then
			for k = 0,1,0.1 do
				gui.BackgroundTransparency = k
			end
			Open = false
		end
	end
end

mouse.KeyDown:connect(PressE)

This script doesn't label any errors nor does it do anything. Please fix!

1 answer

If there are no errors, and this does not fuction, consider checking the if statements, and the function. Either "mouse.KeyDown:connect(PressE)" is not activating (could be incorrect), or one of the if statements is not going through. Place print statements along different points in a script. This is known as print debugging. Place one after every if statement, to see which ones are functioning. If all of them are working, that means something is wrong with your gui.

1 comment

0

Also, KeyDown is deprecated. UserInputService is much more reliable than KeyDown now.

This discussion is preserved as it was. New answers, comments, and votes are closed.