So I'm gonna give some context here for you guys to help me. So basically I want to make my character have a shockwave appear around them when they hold in C, like a Naruto Chakra Charge. I have no idea where to start so i don't have any code to show, sorry. Also if you have time I'd love if you added comments to teach me a little. Thank you!!!
How to make a brick appear when a user holds in a key?
2 answers
I just tried this and it worked fine
local inputService = game:GetService("UserInputService")
local isHoldingDownKey = false
inputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode.C then
isHoldingDownKey = true
-- shockwave appear code should go here
end
end
end)
inputService.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.C then
isHoldingDownKey = false
-- the player isn't holding down the C key anymore.
end
end
end)
This needs to be in a LocalScript btw, and on the client (I put it in the StarterPack folder)
Hope this helps.
First, since you want it to be for the client, then you'd have to use a LocalScript.
To check for the user input, you'd want to use the UserInputService.
Example:
local UserInputService = game:GetService("UserInputService")
--this will check for when the input begins
UserInputService.InputBegan:Connect(function(Input)
--we are using KeyCode since you want a key.
--this will check for when you hold down C
if Input.KeyCode == Enum.KeyCode.C then
--code
end
end)
--and when the input ends
UserInputService.InputEnded:Connect(function(Input)
--this will activate whenever you stop holding down C
if Input.KeyCode == Enum.KeyCode.C then
--code
end
end)
I would like to show you the rest but I'm quite busy at the moment.
So that's the basics covered.
if you want everyone to see that the client is charging, then you'd want to use a RemoteEvent with the function :FireServer() and it's callback which is .OnServerEvent.
When it comes to changing the transparency for a part, it should be obvious that you are going to be changing the property .Transparency to 0 for it to appear and 1 to disappear.
I hope I covered everything you needed the most.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You will need to learn about UserInputService
If you want to learn more about handling user input, the roblox developer page has some explanations on it: https://developer.roblox.com/en-us/api-reference/class/UserInputService