So when key q is pressed i want my tool transparency to change to 1 but when its already at 1 then it and q is pressed then it changes to 0
COMMUNITY QUESTION
So how do i make a when key pressed?
2 answers
Extending on that comment, look into UserInputService.
Here is an example of how its setup:
function onInputEnded(key)
if key.KeyCode == Enum.KeyCode.Q then
-- Do stuff
end
end
game:GetService('UserInputService').InputEnded:Connect(onInputEnded)
This event returns an InputObject as the first parameter. You can use the .KeyCode property to check if the player has pressed a certain key.
As for the toggling of visibility, an easy trick is to use a boolean to check its current state.
3 comments
0
^^^ A perfect answer.
0
Very well agreed, actually helped me as well.
0
thank you, but one more thing. So i made the bool value for toggling visibilty. so do i make another function for when the key was pressed?
you can use else if statement with the transparency
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Look into UserInputService.