What I'm trying to say is that for instance, if somebody pressed the"E" key on their keyboard, they would get a gun or something. Is there any way to detect if someone pressed the key? Thank you!
You need to use a LocalScript to access the PlayerMouse Object, and then you can set up a KeyPressed Event and check what key the pressed.
http://wiki.roblox.com/index.php?title=PlayerMouse
There is a KeyDown
event
Put a LocalScript
inside the StarterPack
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() function PressedE(key) end Mouse.KeyDown:connect(PressedE)
Now the above code is only a way to start it off it doesn't have any relation with key e yet
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() function PressedE(key) Key = key:lower() --I'm just used to doing this..I don't think you have to if Key == "e" then print("Key e was pressed") end end Mouse.KeyDown:connect(PressedE)
Now the above code detects that e was pressed and it prints to the output.
Here is it in other words:
The Player = a Local Player Mouse is Getting the Mouse
If the Key pressed is e then print to the output
If the the Mouse's Key is pressed it will connect the function PressedE. And that function detects if e was pressed. So that's basically how you do it. Sorry if it's a bit sloppy.
I'd be glad if this helped :)