|
| 23 Mar 2012 08:55 PM |
How do I activate something when you press the Q button while the weapon is equipped?
For Example, let's say you have a staff equipped, and you want your health go higher, how do you activate the increase in health by pressing the Q button on the keyboard? |
|
|
| Report Abuse |
|
|
|
| 23 Mar 2012 08:56 PM |
In a local script...
local t = script.Parent
t.Equipped:connect(function(mouse) mouse.KeyUp:connect(key) if key == "q" then -- Code for q pressing end end) end) |
|
|
| Report Abuse |
|
|
crazyzee
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 275 |
|
|
| 23 Mar 2012 08:57 PM |
well first you need a hopperbin of course. and the OnKeyDown function.
~ :{ ) moustache ~ |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 23 Mar 2012 09:02 PM |
@Happy
No.. A LocalScript is for a HopperBin. The .Equipped event is for Tools, while the .Selected event is for HopperBins. |
|
|
| Report Abuse |
|
|
|
| 23 Mar 2012 09:03 PM |
...Actually no. A local script is for CLIENT action, avoiding the server side. You CAN use it in a tool, because the character is actually a client object replicated to the server via Workspace.
And I know...he asked for a tool event. So I gave him one. I've been scripting for four years, thank you. |
|
|
| Report Abuse |
|
|
|
| 23 Mar 2012 09:53 PM |
| ...So where do I put the localscript do i put it in the tool? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 23 Mar 2012 10:14 PM |
Ok here is the script that activates on q:
function Power(key) key = key:lower() if key == "q" then script.Parent.Shield.Disabled = false script.Disabled = true end end
And then it triggers this script (ShieldActivation is the name of the localscript above):
local m = Instance.new("Model") m.Parent = game.Workspace
for angle = 1, 360, 6 do local p = Instance.new('Part') p.Parent = m p.Size = Vector3.new(5,500,5) p.Anchored = true p.BrickColor = BrickColor.new("Deep orange") p.Shape = Cylinder p.Transparency = 0.3 p.CFrame = script.Parent.Parent * CFrame.Angles(math.rad(angle), 0, 0) * CFrame.new(15, 0, 0) wait() end
wait(10) local d = m:GetChildren() for i=0.3, 1, 0.1 do d.Transparency = i end script.Parent.ShieldActivation.Disabled = false script.Disabled = true
Is there any error or problem with these two scripts? |
|
|
| Report Abuse |
|
|