|
| 14 May 2015 02:23 PM |
Hi guys!
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() gui = script.Parent.Menu.Frame Open = false Mouse.KeyDown:connect(function(key) if key:lower() == "m" then gui.Visible = not gui.Visible end end)
I have this script - it works if I press Shift and m making it an uppercase, but it doesn't work just pressing normally :/ Any ideas? Thanks |
|
|
| Report Abuse |
|
|
|
| 14 May 2015 02:29 PM |
local UIS = game:GetService("UserInputService") local gui = script.Parent.Menu.Frae local Open = false
UIS.InputBegan:connect(function(input) if input.KeyCode == 109 then gui.Visible = not gui.Visible end end) |
|
|
| Report Abuse |
|
|
|
| 14 May 2015 02:37 PM |
| Thanks! but it doesn't work :( |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 14 May 2015 02:50 PM |
| then place some prints and check where it goes wrong :) |
|
|
| Report Abuse |
|
|
|
| 14 May 2015 03:19 PM |
I mispelled Frame, but just in case I still added the prints:
local UIS = game:GetService("UserInputService") print("UIS exists: ", UIS.Name) local gui = script.Parent.Menu.Frame print("gui exists: ", gui.Name) local Open = false print("Open set: ", Open)
UIS.InputBegan:connect(function(input) print("INPUT!") if input.KeyCode == 109 then print("M PRESSED") gui.Visible = not gui.Visible print("Visible: ", gui.Visible) end end) |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 02:50 PM |
Thanks! It is so weird :( It is registering "INPUT!" but not showing the gui :/ |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 03:09 PM |
try to place
print(input.KeyCode)
after
print("INPUT!")
maybe that will give us some info. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 03:13 PM |
local contextService = game:GetService("ContextService") local frame = script.Parent:WaitForChild("Menu"):WaitForChild("Frame")
local function toggleGuiVisiblity(actionName, inputState, inputObject) if inputState == Enum.UserInputState.Begin then frame.Visible = not frame.Visible end end
contextService:BindAction("toggleGuiVisibility", toggleGuiVisiblity, false, Enum.KeyCode.M) |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 03:19 PM |
NOOOOOO
NOT THE contextService!!! D:
(I have a trauma with that service) xD |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 02:32 PM |
I still haven't fixed it :/ Very confused.
This works but only if you press Shift and M making it an uppercase?!
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() gui = script.Parent.Menu.Frame Open = false Mouse.KeyDown:connect(function(key) if key:lower() == "m" then gui.Visible = not gui.Visible end end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 17 May 2015 02:38 PM |
| That means the frame doesn't exist. |
|
|
| Report Abuse |
|
|
|
| 21 May 2015 02:19 PM |
It is. For some weird reason, this works but only if I make it uppercase by pressing shift and M - Any ideas?! My caps lock is not on. Thanks
local uis = game:GetService('UserInputService')
local gui = script.Parent.Menu.Frame
uis.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.M then gui.Visible = not gui.Visible end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 May 2015 03:08 PM |
http://wiki.roblox.com/index.php?title=Keyboard_input#math.noise
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.M then print("M was pressed") end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) |
|
|
| Report Abuse |
|
|
|
| 21 May 2015 03:10 PM |
| Thanks but it only prints "M was pressed" when I press Shift and M making it an uppercase? It is so weird :( Any ideas? |
|
|
| Report Abuse |
|
|
|
| 21 May 2015 03:36 PM |
so. let me have this clear
Is your problem that the function is only called when you press shift+m and not if you only press m?
Or is your problem that you want to check if shift is pressed so you can see if it's 'm' or 'M'? |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 02:23 AM |
"Is your problem that the function is only called when you press shift+m and not if you only press m?"
^^^ this :( |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 02:49 AM |
| Wierd. I used checked my code and it worked in both cases. I think ROBLOX doesn't understand your keyboard correctly. I'm not sure you could do anything about that. Maybe contact ROBLOX support for this issue??? |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 05:11 AM |
| Thats really weird and annoying?! Hmm. But in other games, I have pressed M to open the menu and it worked fine?! I am using the same script as them as well! :( |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 05:23 AM |
Maybe it's a ROBLOX studio bug? Try to publish it and check if it works then (F10 to get the output in ROBLOX player)
Otherwise I'm clueless on what causes this, and how to fix this. |
|
|
| Report Abuse |
|
|