Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Foridex 46
6 years ago
Edited 6 years ago
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

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago

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.

0
Also, KeyDown is deprecated. UserInputService is much more reliable than KeyDown now. JellyYn 70 — 6y
Ad

Answer this question