I just started working on a Hide and Seek project but I want to make it different. I want to make it so the when you hold down "E", it allows you hide under the bed or even in a wardrobe and while you are hidden in that area your character becomes invisible until you move away from the hiding place.
✓ ANSWER ACCEPTED
How do I make a keybind event?
1 answer
✓ Accepted answer
To process user input, you should use the UserInputService.InputBegan event client-side, like so:
local Services = {
UserInput = game:GetService("UserInputService")
}
Services.UserInput.InputBegan:Connect(function(InputObject, GameProcessedEvent)
if GameProcessedEvent then
return
end
if InputObject.KeyCode ~= Enum.KeyCode.E then
return
end
-- The user pressed the 'e' key, and the input isn't handled by Roblox.
end)
We define a second parameter for our event listener, GameProcessedEvent. This will be a boolean value that is false when Roblox is not handling the user input, and true if it is (such as if the player is typing in chat the word "hello", we don't want to run our code!
The rest would be up to you. To make the character invisible, you can set the BasePart.Transparency property of the player's character's body parts.
This discussion is preserved as it was. New answers, comments, and votes are closed.
