|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 21 Jun 2014 07:36 PM |
| What about the unequiping part! :( |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 21 Jun 2014 08:13 PM |
| That didn't work either :( |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|