Answered by
6 years ago Edited 6 years ago
Use UserInputService, also you were spelling 'Transparency' incorrectly.
UserInputService, somewhat like ContextActionService, will provide you a way to detect all sorts of input on the client. It includes events such as:
- InputBegan: when an input begins, such as pressing a key down.
- InputEnded: when an input ends, such as letting go of said key.
- InputChanged: when an input is changed, useful for things like mouse movement.
All of these events can be connected to a function with an "input" argument, which you'll use to check what kind of input is being received, as well as the optional boolean "gameProcessedEvent." gameProcessedEvent will be true if the input is being handled elsewhere in the game, such as typing in the chat.
Values of input can be checked using the Enum library, such as Enum.KeyCode
Here is a solution that will work for you:
01 | local player = game.Players.LocalPlayer |
02 | local userInput = game:GetService( "UserInputService" ) |
04 | userInput.InputBegan:Connect( function (input, processed) |
05 | if not processed and input.KeyCode = = Enum.KeyCode.E then |
06 | game.Workspace.eno.Transparency = 0 |
07 | game.Workspace.owt.Transparency = 0 |
08 | game.Workspace.eerht.Transparency = 0 |
09 | game.Workspace.ruof.Transparency = 0 |
Keep in mind, if you want the Transparency changes to replicate to the server and other clients, you'll need to use RemoteEvents/RemoteFunctions and change the transparency in a server script.
More can be learned about UserInputService/Enums here:
https://developer.roblox.com/api-reference/class/UserInputService
https://developer.roblox.com/api-reference/enum/KeyCode
https://developer.roblox.com/api-reference/enum/InputType