|
| 02 Mar 2015 04:55 PM |
I have the script made (it was tough enough as it was) but now I'm looking for a way to have ammo. The players ammo is unlimited, but the clip should be limited. How would I do that?
Heres the script:
local tool = script.Parent local user local isfiring
tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() isfiring = true while isfiring do -- make and do a hit test along the ray tool.Handle.Fire:Play() local ray = Ray.new(tool.Barrel6.CFrame.p, (mouse.Hit.p - tool.Barrel6.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user) -- do the damage to a humanoid local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(5) end -- draw ray local distance = (position - tool.Barrel6.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright yellow") rayPart.Transparency = .5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, tool.Barrel6.CFrame.p) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(rayPart, 0.1) wait(.1) end end) mouse.Button1Up:connect(function() isfiring = false end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Mar 2015 05:18 PM |
http://wiki.roblox.com/index.php?title=How_to_Make_a_Raycasting_Lasergun
Did you really make it? If you did, clips wouldn't be a problem...
Basic flow chart (assuming you do know something):
-- User clicks -- Checks if user is reloading -- Shoot if not -- Take away 1 bullet -- if User has 0 bullets -- Say they are reloading -- Wait a few seconds -- Set bullets back -- Say they are not reloading
The alternative is just checking if it's zero but you should get it. |
|
|
| Report Abuse |
|
|
Saldor010
|
  |
| Joined: 20 Sep 2010 |
| Total Posts: 1035 |
|
|
| 02 Mar 2015 05:20 PM |
| Um, yeah, if you know enough to write a gun script, you know how to use some variables and if statements. |
|
|
| Report Abuse |
|
|