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
 

Activation on Q

Previous Thread :: Next Thread 
Mariocool925 is not online. Mariocool925
Joined: 09 Nov 2010
Total Posts: 103
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
XhappysmileX is not online. XhappysmileX
Joined: 22 Feb 2009
Total Posts: 124
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 is not online. 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 is not online. 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
XhappysmileX is not online. XhappysmileX
Joined: 22 Feb 2009
Total Posts: 124
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
Mariocool925 is not online. Mariocool925
Joined: 09 Nov 2010
Total Posts: 103
23 Mar 2012 09:53 PM
...So where do I put the localscript do i put it in the tool?
Report Abuse
XhappysmileX is not online. XhappysmileX
Joined: 22 Feb 2009
Total Posts: 124
23 Mar 2012 09:53 PM
Yes

>.>
Report Abuse
Mariocool925 is not online. Mariocool925
Joined: 09 Nov 2010
Total Posts: 103
23 Mar 2012 09:57 PM
it didn't work
Report Abuse
Mariocool925 is not online. Mariocool925
Joined: 09 Nov 2010
Total Posts: 103
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
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