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

Image transparency wont work?

Asked by
Oullim 0
8 years ago
function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        game.StarterGui.uh.ImageLabel.ImageTransparency = 0
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)

Everything works no error just doesn't perform...

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

You problem is that you are trying to access ContextActionService as if it were a member of game when in reality it is actually a service that need to be retrieved before it can be used.

In order to retrieve it, you can use the method of game :GetService():

local contextAction = game:GetService("ContextActionService")

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        game.StarterGui.uh.ImageLabel.ImageTransparency = 0
    end
end

contextAction:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)
Ad

Answer this question