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 Herlp!

Previous Thread :: Next Thread 
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 07:16 PM
This works and all but can some one make it to where if the person presses q again it DeEquips it or somfin :)?


local Enabled = true
local Player = script.Parent.Parent

mouse = Player:GetMouse()
function onKeyDown(key)
if not Enabled then return end
Key = key:lower()
if key == "q" then
Enabled = false
Player.Character.Humanoid:EquipTool(Player.Backpack.InfantG)
end
Enabled = true
end
mouse.KeyDown:connect(onKeyDown)
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 07:27 PM
If I didn't explain that well how about this... Once you press q you equip the tool
so when you press it again I want it to unequip it
Report Abuse
tentastic2 is not online. tentastic2
Joined: 03 May 2009
Total Posts: 241
21 Jun 2014 07:31 PM
Each tool object has a bool value called "Enabled" or something along those lines.

You wrote it a bit wrong; a better way would be:

local Enabled = false
local Player = script.Parent.Parent

mouse = Player:GetMouse()
function onKeyDown(key)
Key = key:lower()
if Key == "q" then
if Enabled then
Enabled = false
Player.Character:findFirstChild(InfantG).Enabled = false
else
Enabled = true
Player.Backpack.InfantG.Enabled = true
Player.Character.Humanoid:EquipTool(Player.Backpack.InfantG)
end
end
end
mouse.KeyDown:connect(onKeyDown)
Report Abuse
tentastic2 is not online. tentastic2
Joined: 03 May 2009
Total Posts: 241
21 Jun 2014 07:33 PM
Sorry for not explaining myself-

If you have a tool equiped and you make it's enabled value false- it automatically deselects that tool.

So if you have it equipped, all you need to do is go and find that value and make it false- therefore successfully equipping it.
Report Abuse
tentastic2 is not online. tentastic2
Joined: 03 May 2009
Total Posts: 241
21 Jun 2014 07:34 PM
And I forgot to add quotations from the

findFirstChild("InfantG")

in the part I wrote.
Sorry, I've been scripting all day.
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 07:36 PM
What about the unequiping part! :(
Report Abuse
tentastic2 is not online. tentastic2
Joined: 03 May 2009
Total Posts: 241
21 Jun 2014 07:37 PM
I added that.


I put that if it found the tool and it was enabled; then to find that tool and disable it.

But if the enabled value is false, to enable it.
Report Abuse
tentastic2 is not online. tentastic2
Joined: 03 May 2009
Total Posts: 241
21 Jun 2014 07:46 PM
If it still doesn't work; then this should:


local Enabled = false
local Player = script.Parent.Parent

mouse = Player:GetMouse()
function onKeyDown(key)
Key = key:lower()
if Key == "q" then
if Enabled then
Enabled = false
Player.Character:findFirstChild("InfantG").Parnet = Player.Backpack
else
Enabled = true
Player.Backpack.InfantG.Enabled = true
Player.Character.Humanoid:EquipTool(Player.Backpack.InfantG)
end
end
end
mouse.KeyDown:connect(onKeyDown)
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 08:13 PM
That didn't work either :(
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 08:21 PM
Okay I fixed it... I was looking at Parnet i'm like what the hell is Parnet it looks legit but idk what it is so I went to the wiki it didn't have it there so I was like... maybe I should check the tool so I went in the tool and I seen Parent then I was like OHHH THIS FOOL SPELT IT WRONG!
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
21 Jun 2014 10:12 PM
Um why doesn't this work? the out put says there's a nil value on line 10


local Enabled = false
local Player = script.Parent.Parent

mouse = Player:GetMouse()
function onKeyDown(key)
Key = key:lower()
if Key == "e" then
if Enabled then
Enabled = false
Player.Character:findFirstChild("BarricadeG").Parent = Player.Backpack
else
Enabled = true
Player.Backpack.BarricadeG.Enabled = true
Player.Character.Humanoid:EquipTool(Player.Backpack.BarricadeG)
end
end
end
mouse.KeyDown:connect(onKeyDown)
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