|
| 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 |
|
|
|
| 29 Apr 2012 09:29 PM |
| If you actually made this then you would know how to fic it... |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|