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

Image transparency wont work?

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

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)

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