|
| 17 Feb 2017 12:04 AM |
| How do I use input.KeyCode to change ### color of a player? |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2017 12:10 AM |
| http://wiki.roblox.com/?title=API:Class/UserInputService |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 17 Feb 2017 01:17 AM |
| I can help lower life forms. :c |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 08 Jul 2011 |
| Total Posts: 985 |
|
|
| 17 Feb 2017 04:35 AM |
| HAHAHAH "Lua_Basics" HAHAHAH |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
|
| 17 Feb 2017 02:48 PM |
| But thank you, its interesting to see the different ways people approach keyboard input |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|