|
| 10 Apr 2014 11:01 PM |
Hi,
My script is trying to make it so that when the player hits 'z,' certain GUI's turn Visible. However, because of it having to be a normal script, I am having trouble trying to find the mouse. Anyone know how to do this?
local player = script.Parent.Parent.Parent.Parent --Double checked this, it's correct. local mouse = player:GetMouse()
local function keyDown(key) if key == "z" then script.Parent.Parent.Credits.A.Visible = true script.Parent.Parent.Help.A.Visible = true script.Parent.Parent.Help.Visible = true script.Parent.Parent.Credits.Visible = true script.Parent.Text = "Close[E]" end end mouse.KeyDown:connect(keyDown) |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 10 Apr 2014 11:03 PM |
| You can't use GetMouse without a localscript. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 11:22 PM |
Plr = game.Players.LocalPlayer mouse = Plr:GetMouse() mouse.KeyDown:connect(function(key) if key == "z" then
Plr.PlayerGui.ScreenGui.Credits.A.Visible = true Plr.PlayerGui.ScreenGui.Help.A.Visible = true Plr.PlayerGui.ScreenGui.Help.Visible = true Plr.PlayerGui.ScreenGui.Credits.Visible = true Plr.PlayerGui.ScreenGui.TextLable.Text = "Close[E]" end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Apr 2014 11:36 PM |
h = Instance.new 'Hint'; h.Parent = game.Workspace h.Text = "Dont remove this, created by McChicken72!" local mouse = player:GetMouse()
local function keyPress(key) if key == "e" --do stuff wanan add more? elseif key == "g" -- Add more.. this wont affect but you can remove this and the G key line. end end mouse.KeyDown:connect(keyPress) |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 11:36 PM |
| remove wanan add more? cuz i spelt it rong and forgot to add -- (two dashes for free scribble!) |
|
|
| Report Abuse |
|
|
zbaddude2
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 1897 |
|
|
| 10 Apr 2014 11:45 PM |
| What do you mean by local script? Are we talking about a private/public instance data/methods here? Or are we talking about a static class? |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Apr 2014 01:50 AM |
texastech717 Why does it have to be a Script not a LocalScript? Preferably since GUI is a locally rendered thing, it's scripts are LocalScripts too. That also gives it a lot more power with the local user.
Anyways, if the script MUST be a Script type, then have you thought about making a SECOND script inside it that does local things like toggling it's visibility on keypress? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2014 02:25 AM |
| Tecmag texa doesn't know what a local script is. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2014 02:32 AM |
Why would you say that? He never said in this post he didn't.
He DID say "However, because of it having to be a normal script, I am having trouble trying to find the mouse." Which pretty well is saying, "I know what a Normal script is as opposed to a LocalScript and that I can't get the mouse because normal scripts don't have access to the same calls as LocalScripts" |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2014 02:33 AM |
| Adding to that, your script wouldn't work if it wasn't in a LocalScript, so. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2014 02:56 AM |
| Well the script I gave him should work all he has to do is put it in a local script then stick it in starter gui or starter gear |
|
|
| Report Abuse |
|
|
MTamidex
|
  |
| Joined: 17 Oct 2013 |
| Total Posts: 1092 |
|
|
| 11 Apr 2014 05:00 AM |
local player = script.Parent.Parent.Parent.Parent --Double checked this, it's correct. local mouse = player:GetMouse()
local function keyDown(key) if key:byte()==122 then script.Parent.Parent.Credits.A.Visible = true script.Parent.Parent.Help.A.Visible = true script.Parent.Parent.Help.Visible = true script.Parent.Parent.Credits.Visible = true script.Parent.Text = "Close[E]" end end mouse.KeyDown:connect(keyDown)
--Local script!!!! |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2014 10:05 AM |
Thanks guys!
---------------------THREAD CLOSED--------------------- |
|
|
| Report Abuse |
|
|