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 » Scripting Helpers
Home Search
 

Re: KeyDown Help (Simple, I think...)

Previous Thread :: Next Thread 
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
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 is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
10 Apr 2014 11:03 PM
You can't use GetMouse without a localscript.
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
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
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
10 Apr 2014 11:24 PM
You have to edit it some.
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
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
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
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 is not online. 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
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
11 Apr 2014 01:32 AM
Wtf? dude get out.
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
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
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
11 Apr 2014 02:25 AM
Tecmag texa doesn't know what a local script is.
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
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
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
11 Apr 2014 02:33 AM
Adding to that, your script wouldn't work if it wasn't in a LocalScript, so.
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
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 is not online. 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
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
11 Apr 2014 10:05 AM
Thanks guys!

---------------------THREAD CLOSED---------------------
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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