Do not use if ..:Connect only use ...:Connect, :connect and Mouse.KeyDown/Up is deprecated. use :Connect and UserInputService.InputBegan/InputEnded.
Example:
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
uis.InputBegan:Connect(function(input,proc)
if not proc and input.KeyCode == Enum.KeyCode.E then
char:WaitForChild("Humanoid").WalkSpeed = 200
end
end)
uis.InputEnded:Connect(function(input,proc)
if not proc and input.KeyCode == Enum.KeyCode.E then
char:WaitForChild("Humanoid").WalkSpeed = 16
end
end)
What is UserInputService?
- The UserInputService is a service used to detect and capture the different types of input available on a user’s device.
What is UserInputService.InputBegan?
- The InputBegan event fires when a user begins interacting via a Human-Computer Interface device (mouse button down, touch begin, keyboard button down, etc.).
What is UserInputService.InputEnded?
- The InputEnded event fires when a user stops interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc). This is useful when tracking when a user releases a keyboard key, mouse button, touchscreen input, etc. This event can be used along with UserInputService.InputBegan and UserInputService.InputChanged to track when user input begins, changes, and ends.
What is proc?
- gameProcessedEvent / Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessedEvent would be true. This is also true for input events connected via
ContextActionService
This is in wiki.
Hope it helped :)
Wiki pages:
- UserInputService
- WaitForChild
Solved your problems? put [SOLVED] in title or accept a answer.
3 comments
Clearly you do not understand Lua syntax, you should take a look at the wiki or the PiL as a reference
Clearly you don't understand this is a place for people to learn. If someone's asking a question here, it's probably because the forums and wiki crap made no sense to them, and they would like some personal help from people with experience.
Yes, however how they made it this far and want to do something a bit more complex like make a player do something when "E" is pressed is insane. All of this is covered in the wiki's tutorial which tells you how to manipulate a brick.