|
| 02 Sep 2011 04:26 PM |
| Any way to utilize loops/values to make a gun automatic? |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Sep 2011 04:41 PM |
| Yes, how is this a problem? |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2011 04:42 PM |
| Idk, butwhen I use my knowledge of it, the minigun fails to fire. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Sep 2011 05:05 PM |
Guys what?
What do you want! |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2011 05:06 PM |
| I want some help on some way to use a loop to make a stupid automatic gun! |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Sep 2011 08:42 PM |
| Almost forgot, using loops on raycasting(horrible keyboard) |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Sep 2011 11:18 AM |
| maybe if you post the script you have so far, we can find the problem. |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Sep 2011 11:33 AM |
Clarification: How to use a loop with this script: local Tool = script.Parent --Set a variable for the tool. local User --Create a nil value for the character which we can't find yet. Tool.Equipped:connect(function(mouse) --When it's equipped fire a function. User = Tool.Parent --Set the User variable to the character of the person using the tool. mouse.Button1Down:connect(function() --When the left mouse button is clicked fire a function. Tool.Handle.Fire:play() local Ray = Ray.new(Tool.Handle.CFrame.p,(mouse.Hit.p-Tool.Handle.CFrame.p).unit*300) --Make a the ray. local Hit,Position = game.Workspace:FindPartOnRay(Ray,User) --Check for collisions along the ray. if Hit then --If it hits something. if Hit.Parent:FindFirstChild("Humanoid") then --If the thing the ray hit has a humanoid. Hit.Parent.Humanoid:TakeDamage(50) --Do 30 damage if they don't have a forcefield. end --End the humanoid check. end --End the hit check. local RayPart = Instance.new("Part",User) --Create a part in the user. RayPart.Name = "RayPart" --Set its name. RayPart.BrickColor = BrickColor.new("Bright green") --Set its color. RayPart.Transparency = 0.1 --Set its transparency. RayPart.Reflectance = 0.1 RayPart.Anchored = true --Set whether it will fall or not. RayPart.CanCollide = false --Set whether people can walk though it or not. RayPart.TopSurface = Enum.SurfaceType.Smooth --Make it smooth on the top. RayPart.BottomSurface = Enum.SurfaceType.Smooth --Make it smooth on the bottom. RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small. local Distance = (Position-Tool.Handle.CFrame.p).magnitude --Find the distance between the click and the gun. RayPart.Size = Vector3.new(0.2,0.2,Distance) --Set its size to the distance. RayPart.CFrame = CFrame.new(Position,Tool.Handle.CFrame.p) * CFrame.new(0,0,-Distance/2) --Move it halfway. game.Debris:AddItem(RayPart,0.1) --Add it to the debris. wait(2) end) end) To make a automatic gun? |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 11:42 AM |
| Useless bump(on first page) |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 11:45 AM |
| >.> Just run it until it fires the .Button1Up event? |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 11:48 AM |
| I'll try... I'm not much of a scripter |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 12:11 PM |
| ._. I can't firgure out how. |
|
|
| Report Abuse |
|
|
| |
|
Fredfishy
|
  |
| Joined: 21 Mar 2009 |
| Total Posts: 4197 |
|
|
| 03 Sep 2011 12:17 PM |
is_firing = false
function onButton1Down(mouse) while is_firing do print("BEWM") e = Instance.new("Explosion", Workspace) e.Position = mouse.Hit.p e.BlastPressure = 1000000 e.BlastRadius = 9001 wait() end end
function onEquipped(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
script.Parent.Equipped:connect(onEquipped) |
|
|
| Report Abuse |
|
|
Fredfishy
|
  |
| Joined: 21 Mar 2009 |
| Total Posts: 4197 |
|
|
| 03 Sep 2011 12:18 PM |
Fail script was fail :c
is_firing = false
function onButton1Up(mouse) is_firing = false end
function onButton1Down(mouse) is_firing = true while is_firing do print("BEWM") e = Instance.new("Explosion", Workspace) e.Position = mouse.Hit.p e.BlastPressure = 1000000 e.BlastRadius = 9001 wait() end end
function onEquipped(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) end
script.Parent.Equipped:connect(onEquipped) |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 12:20 PM |
| Not using explosions. Using raycasting to make a SMG lasergun. |
|
|
| Report Abuse |
|
|
| |
|
Fredfishy
|
  |
| Joined: 21 Mar 2009 |
| Total Posts: 4197 |
|
|
| 03 Sep 2011 12:29 PM |
| Yus, but you can just edit that to suit your needs. Or edit your original script or whatever. |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2011 12:31 PM |
Crap. Integrate a script and it breaks.
is_firing = false
function onButton1Up(mouse) is_firing = false end
function onButton1Down(mouse) is_firing = true while is_firing do Tool.Handle.Fire:play() local Ray = Ray.new(Tool.Handle.CFrame.p,(mouse.Hit.p-Tool.Handle.CFrame.p).unit*300) --Make a the ray. local Hit,Position = game.Workspace:FindPartOnRay(Ray,User) --Check for collisions along the ray. if Hit then --If it hits something. if Hit.Parent:FindFirstChild("Humanoid") then --If the thing the ray hit has a humanoid. Hit.Parent.Humanoid:TakeDamage(5) --Do 30 damage if they don't have a forcefield. end --End the humanoid check. end --End the hit check. local RayPart = Instance.new("Part",User) --Create a part in the user. RayPart.Name = "RayPart" --Set its name. RayPart.BrickColor = BrickColor.new("Bright green") --Set its color. RayPart.Transparency = 0.1 --Set its transparency. RayPart.Reflectance = 0.1 RayPart.Anchored = true --Set whether it will fall or not. RayPart.CanCollide = false --Set whether people can walk though it or not. RayPart.TopSurface = Enum.SurfaceType.Smooth --Make it smooth on the top. RayPart.BottomSurface = Enum.SurfaceType.Smooth --Make it smooth on the bottom. RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small. local Distance = (Position-Tool.Handle.CFrame.p).magnitude --Find the distance between the click and the gun. RayPart.Size = Vector3.new(0.2,0.2,Distance) --Set its size to the distance. RayPart.CFrame = CFrame.new(Position,Tool.Handle.CFrame.p) * CFrame.new(0,0,-Distance/2) --Move it halfway. game.Debris:AddItem(RayPart,0.1) --Add it to the debris. wait(0.2) end end
function onEquipped(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) end
script.Parent.Equipped:connect(onEquipped) |
|
|
| Report Abuse |
|
|
Fredfishy
|
  |
| Joined: 21 Mar 2009 |
| Total Posts: 4197 |
|
| |
|