generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: KeyBoard Input

Previous Thread :: Next Thread 
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 12:04 AM
How do I use input.KeyCode to change ### color of a player?
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Feb 2017 12:10 AM
http://wiki.roblox.com/?title=API:Class/UserInputService
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 12:16 AM
Not Helpful at all "Lua_Basics" Ive already searched the wiki and InputBegan is not helping the situation either.
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Feb 2017 12:41 AM
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan

local function onInputBegan(input,gameProcessed)
if not gameProcessed then
print("A key is being pushed down! Key:",input.KeyCode)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("The left mouse button has been pressed down at",input.Position)
end
end
end

UserInputService.InputBegan:connect(onInputBegan)
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Feb 2017 12:42 AM
So, we get the event when they press a key or hit a button on xbox. Before we do anything we must check if they are chatting or anything before we do this so it works smoothly. Then We have to define whats being pressed and where its coming from, like a keyboard.
Report Abuse
Isosta is not online. Isosta
Joined: 10 May 2015
Total Posts: 14729
17 Feb 2017 12:58 AM
mfw he just insulted you in a sarcastic manner and u still help him


R$90,865 and climbing.
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Feb 2017 01:17 AM
I can help lower life forms. :c
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
17 Feb 2017 04:16 AM
Haha, you guys are ridiculous.

OP said you were unhelpful because that was actually the case. Telling people to "just read the docs" is fine if you're talking to people who already have experience programming and working with an engine. But to total beginners, a wiki page might not be as helpful as it is to us.

So far OP is a beginner asking for help, and you guys are being sarcastic and offending them. Who's the lower life form again?
Report Abuse
toflyc is not online. toflyc
Joined: 08 Jul 2011
Total Posts: 985
17 Feb 2017 04:35 AM
HAHAHAH "Lua_Basics" HAHAHAH
Report Abuse
sircfenner is not online. sircfenner
Joined: 29 Aug 2008
Total Posts: 2430
17 Feb 2017 04:36 AM
Lua_Basics did a great job. If anybody ever helps you in good faith, you should never dismiss them as 'unhelpful'. You say thank you, and then explain why you still need more help. This forum is not for people to write scripts for you.
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
17 Feb 2017 04:45 AM
Lua_Basics did a great job of being condescending and lazy, and most certainly not in good faith. This forum shouldn't be for people to be mean to each other. You might think that not saying "thanks" and "excuse me" and "please" all ### time is rude, but I certainly don't agree.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
17 Feb 2017 05:08 AM
LOL

the wiki gives a CLEAR example on how to use key input, if he can't understand even THAT, he should start somewhere smaller


Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Feb 2017 05:39 AM
Color of a player?

That's slightly confusing, not exactly sure what you are asking.

Here's a basic UserInputService setup:

local uis = game:GetService("UserInputService")
local key = "G"

uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode[key] then
--do something
end
end)
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
17 Feb 2017 07:15 AM
I think I understand whats he saying. I think he wants a script to change the colors of the baseparts of the player when they click a key on thier keyboard.

local player = game.Players.LocalPlayer

game:GetService("UserInputService").InputBegan:connect(function(inputObject, event)
if event then return end
if inputObject.KeyCode == Enum.KeyCode.LeftParenthesis then
for _,part in pairs(player.Character:GetChildren()) do
if part:IsA("BasePart") then
part.BrickColor = BrickColor.Random()
end
end
end
end
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Feb 2017 02:14 PM
I posted how to use UIS and properly I forgot to include how to change a part's color in a player, but it isn't the most polite thing to insult someone trying to help.
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 02:30 PM
I'm sorry if i insulted you, I know how to use KeyBoard Input its just that i dont know how to use it to change ### color of a player so being redirected to a wiki that teaches you how to use keyboard input isnt very helpful.
Report Abuse
curtisornot is not online. curtisornot
Joined: 30 Jun 2008
Total Posts: 1271
17 Feb 2017 02:39 PM
local colorChange= {
[Enum.KeyCode.R] = "Really red",
[Enum.KeyCode.B] = "Really blue",
[Enum.KeyCode.G] = "Camo""
}

game:GetService("UserInputService").InputBegan:connect(function(input,gameProcessed)
if colorChange[input.KeyCode] ~= nil then
player.Character.Head.BrickColor = BrickColor.new(colorChange[input.KeyCode])
end
end)

This SHOULD change the players head to a certain color based on certain keyboard input BUT i'm not sure, its untested
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 02:43 PM
Thanks i'll try it out.
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 02:47 PM
Doesnt work
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 02:48 PM
But thank you, its interesting to see the different ways people approach keyboard input
Report Abuse
curtisornot is not online. curtisornot
Joined: 30 Jun 2008
Total Posts: 1271
17 Feb 2017 03:00 PM
Sorry there is an extra quotation mark after "Camo"

Also it has to be a localscript and player has to equal
game.Players.LocalPlayer
Report Abuse
funnyrekell is not online. funnyrekell
Joined: 02 Dec 2011
Total Posts: 19
17 Feb 2017 03:36 PM

local player = game.Players.LocalPlayer
local colorChange= {
[Enum.KeyCode.R] = "Really red",
[Enum.KeyCode.B] = "Really blue",
[Enum.KeyCode.G] = "Camo"
}

game:GetService("UserInputService").InputBegan:connect(function(input,gameProcessed)
if colorChange[input.KeyCode] ~= nil then
player.Character.Head.BrickColor = BrickColor.new(colorChange[input.KeyCode])
end
end)

Yes this works! masterfully done my friend!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image