|
| 19 Feb 2014 09:51 PM |
| Let's say you hit the "K" key. Woah, that part just became red! But how? |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 09:52 PM |
b1 In other words, I want to make a Roblox Punch-Out port, and need to use the keyboard. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 09:57 PM |
Put this in a localscript and put the script into a textbutton and put the button into a gui
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Button = script.Parent
Mouse.KeyDown:connect(function(Key) if Key == "k" then game.Workspace.Part.BrickColor = BrickColor.new("Bright red") end) |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 09:59 PM |
Actually,the localscript he posted,can be put directly into startergui:P StarterGui -LocalScript |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:00 PM |
also @crazy,u forgot an end |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:04 PM |
Use:
:keydown
Like this:
Brick = -- Put the link to the Brick here. Color = ("Red") --Replace Red with the color you want.
function onKeyDown(key) if key == ("K") then Brick.BrickColor = BrickColor.new(Color) end end
mouse.KeyDown:connect(onKeyDown) |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Feb 2014 10:12 PM |
| None of these work, although they look like they should. Also, don't orientate your scripts to make a part red, keep it generic. That was just an example. |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Feb 2014 10:20 PM |
@computer, Colors don't have parentheses around them. Also there are no color called Red
|
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:24 PM |
| You guys are missing the point. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:27 PM |
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
script.Parent.MouseButton1Click(function(onClick) mouse.KeyDown:connect(function(k) if k:byte() == 107 then game.Workspace.Part.BrickColor = BrickColor.new("Bright red") end end) end) |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:29 PM |
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
script.Parent.MouseButton1Click:connect(function(onClick) mouse.KeyDown:connect(function(k) if k:byte() == 107 then game.Workspace.Part.BrickColor = BrickColor.new("Bright red") end end) end)
sorry for got one thing |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 10:33 PM |
LOL MESSED UP
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
mouse.KeyDown:connect(function(k) if k:byte() == 107 then game.Workspace.Part.BrickColor = BrickColor.new("Bright red") end end)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 19 Feb 2014 10:39 PM |
| Yes, but it would help if you could explain the script. I am learning Lua, and this would help a lot. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 11:10 PM |
Here is how it works:
local player = game.Players.LocalPlayer --get the player local mouse = player:GetMouse() --get the player's mouse/keyboard
mouse.KeyDown:connect(function(k) --when the player presses a key, execute the function. 'k' is the key they pressed if k:byte() == 107 then --if the byte of the key pressed is 107 (k's code) then NOTE: you could also do if k == "k" then Workspace.Part.BrickColor = BrickColor.new("Bright red") --change the color end end) |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2014 11:24 PM |
| Isn't that like exactly what I wrote...? |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2014 02:17 PM |
| Crazy, I have no idea why yours didn't work. Maybe you used a different method, and messed up somewhere? Also, where "k"'s code is 107, where can I find the codes for other keys? |
|
|
| Report Abuse |
|
|
jd678
|
  |
| Joined: 18 Apr 2008 |
| Total Posts: 11529 |
|
|
| 20 Feb 2014 02:37 PM |
you dont have to use a byte code
--LocalScript Brick = Workspace:FindFirstChild("Brick") -- the brick you want to change to red Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.KeyDown:connect(function(Key) if Key == "k" then Brick.BrickColor = BrickColor.new("Bright red") end end)
|
|
|
| Report Abuse |
|
|
jd678
|
  |
| Joined: 18 Apr 2008 |
| Total Posts: 11529 |
|
|
| 20 Feb 2014 02:38 PM |
' NOTE: you could also do if k == "k" then '
I should prolly learn to read |
|
|
| Report Abuse |
|
|