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: Machine Gun Hold&Shoot

Previous Thread :: Next Thread 
jeffrey2457 is not online. jeffrey2457
Joined: 12 Mar 2011
Total Posts: 39
29 Apr 2012 09:27 PM
I have made a machine gun, and the script works like I want, except for one part, I want the click and hold machine gun, currently it only works as a fast pistol basically, you have to have a trigger finger basically for it, like click, unclick, click, unclick every time you wanna shoot, this is my script:




originalCap = script.Parent.Capacitor.Value


m = Instance.new("Hint")





function computeDirection(vec)


local lenSquared = vec.magnitude^2


local invSqrt = 1 / math.sqrt(lenSquared)


return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)


end





function updateCapacitor()


m.Text = "["


for i = 1,script.Parent.Capacitor.Value do


m.Text = m.Text .. "|"


end


for i = 1,(originalCap - script.Parent.Capacitor.Value) do


m.Text = m.Text .. " "


end


m.Text = m.Text .. "] Capacitor: " .. script.Parent.Capacitor.Value


end





function fire(v)


for i = 1,1 do


script.Parent.Capacitor.Value = script.Parent.Capacitor.Value - 2


updateCapacitor()


local dir = v - script.Parent["Handle"].Position


dir = computeDirection(dir)


local pos = script.Parent["Handle"].Position + (dir * 8)


local p = Instance.new("Part")


p.Name = "Projectile"


p.CFrame = CFrame.new(pos, pos + dir)


p.BrickColor = BrickColor.new(199)


p.Reflectance = 0.1


p.Velocity = (script.Parent.Parent["Head"].Position - v).unit * -75


p.Size = Vector3.new(1, 1, 1)


p.formFactor = 2


local mesh = Instance.new("SpecialMesh")


mesh.MeshType = "Sphere"


mesh.Scale = Vector3.new(1, 2, 1)


mesh.Parent = p


local upforce = Instance.new("BodyForce")


upforce.force = Vector3.new(0, p:GetMass() * 196, 0)


upforce.Parent = p


local s = script.Parent["ProjectileScript"]:Clone()


s.Disabled = false


s.Parent = p


p.Parent = game.Workspace


wait(0.005)


end


end





function onActivated()


if script.Parent.Enabled == true then


script.Parent.Enabled = false


if script.Parent.Capacitor.Value >= 2 then


fire(script.Parent.Parent["Humanoid"].TargetPoint)


end


wait(0.25)


script.Parent.Enabled = true


end


end





function onEquipped()


local p = game.Players:GetChildren()


for i = 1,#p do


if p[i].Character == script.Parent.Parent then


m.Parent = p[i]


end


end


updateCapacitor()


end





function onUnequipped()


m.Parent = nil


end





script.Parent.Activated:connect(onActivated)


script.Parent.Equipped:connect(onEquipped)


script.Parent.Unequipped:connect(onUnequipped)





while true do


if script.Parent.Capacitor.Value < originalCap then


script.Parent.Capacitor.Value = script.Parent.Capacitor.Value + 1

updateCapacitor()


end


wait(0.005)


end


Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
29 Apr 2012 09:29 PM
If you actually made this then you would know how to fic it...
Report Abuse
nopepng is not online. nopepng
Joined: 23 Oct 2011
Total Posts: 2063
29 Apr 2012 09:32 PM
There is no error here, josh,

he wants to make it full auto.


I had a function for this on my main, but I'm banned...

Oh well.
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
29 Apr 2012 09:33 PM
fix
Report Abuse
Drenkus is not online. Drenkus
Joined: 03 May 2009
Total Posts: 2380
29 Apr 2012 10:00 PM
Something like,

mousedown=false

function button1down()
mousedown=true
end

function button1up()
mousedown=false
end


Then just make a while loop, that's how I'd do it.
Report Abuse
jeffrey2457 is not online. jeffrey2457
Joined: 12 Mar 2011
Total Posts: 39
01 May 2012 10:44 PM
ok thanks dren.
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
02 May 2012 05:55 PM
What i am saying is, it's not hard to change it to full auto, if he knew how to make all this, then he should be able to make it full auto i mean honestly...
Report Abuse
jeffrey2457 is not online. jeffrey2457
Joined: 12 Mar 2011
Total Posts: 39
02 May 2012 09:26 PM
*Spam* Just checking how long I have played RBLX and how many forum posts I got for calculator.
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