✓ Accepted answer
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:
local player = game.Players.LocalPlayer
local userInput = game:GetService("UserInputService")
userInput.InputBegan:Connect(function(input, processed)
if not processed and input.KeyCode == Enum.KeyCode.E then
game.Workspace.eno.Transparency = 0
game.Workspace.owt.Transparency = 0
game.Workspace.eerht.Transparency = 0
game.Workspace.ruof.Transparency = 0
end
end)
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
1 comment
Is this is a local script?