|
| 12 Aug 2016 05:23 PM |
Hey, Last time I asked how to make a Kick system if they asked someone to date, But me and my friends are making an Aliens vs Humans game, and I wanted to know how to make a gun script, It has to fire, but you don't have to make it so it can zoom in, thanks ;D The reason I'm asking, is that I can't find a tutorial on YT, and I'm extremely new to scripting.
-Swifter
P.S Here's the link to the gun. https://www.roblox.com/Alien-Blaster-item?id=478609283 |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 05:52 PM |
| all you do is change the rotation on the tool its pretty basic i have a basic script i can do it on but it's reallllly basic |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 06:09 PM |
local tool = script.Parent local player = game:GetService("Players").LocalPlayer
tool.Equipped:connect(function(mouse) print("Tool equipped!") mouse.Button1Down:connect(function() print("Mouse pressed!") tool.GripPos = Vector3.new(0,-0.1,0) wait (1) tool.GripPos = Vector3.new(0,0,0) local ray = Ray.new(tool.Barrel1.CFrame.p, (mouse.Hit.p - tool.Barrel1.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("New Yeller") beam.FormFactor = "Custom" beam.Material = "Metal" beam.Transparency = 0.3 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (tool.Barrel1.CFrame.p - position).magnitude beam.Size = Vector3.new(0.05, 0.05, distance) beam.CFrame = CFrame.new(tool.Barrel1.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) local bea = Instance.new("Part", workspace) bea.BrickColor = BrickColor.new("Magent") bea.FormFactor = "Custom" bea.Material = "Neon" bea.Transparency = 0.9 bea.Anchored = true bea.Locked = true bea.CanCollide = false local distance = (tool.Barrel1.CFrame.p - position).magnitude bea.Size = Vector3.new(0,0,0) bea.CFrame = CFrame.new(tool.Barrel1.CFrame.p, position) * CFrame.new(0, 0, -distance / 1) game:GetService("Debris"):AddItem(beam, 0.1) game:GetService("Debris"):AddItem(bea, 0.1)
if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(20) end end end) end)
|
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 06:10 PM |
| its bad but you get the idea |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 06:14 PM |
wiki.roblox.com/index.php?title=Making_a_ray-casting_laser_gun
|
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 06:18 PM |
| Thanks Ninja, I still have one problem. It falls apart, and I can't pick it up. |
|
|
| Report Abuse |
|
|
Pyro_RBLX
|
  |
| Joined: 06 Mar 2016 |
| Total Posts: 12 |
|
|
| 12 Aug 2016 09:35 PM |
| if its falling apart anchor all of the parts that make the gun |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2016 02:17 AM |
Alright, I've fixed everything, One last problem. It fires, it does everything I wanted it to do. But, When I select the tool, all it appears as is a white brick, aka, the handle. I tried putting the bricks to my gun into the tool itself, but that didn't work, Other then that, its working pretty well so far.
-swift
im the dynamite king |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2016 02:18 AM |
| and the gun appears on the floor next to me, :/ forget to mention that |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Aug 2016 12:52 PM |
| don't anchor the handle, weld everything don't acnhor |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 15 Aug 2016 12:55 PM |
This is a basic projectile firing system. Doesn't do damage, but just check if the bullet is touching a object with a humanoid ;).
local pistol = script.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse()
function makeBullet() local Bullet = Instance.new("Part", workspace) Bullet.Name = "Bullet" Bullet.Anchored = false Bullet.CanCollide = false Bullet.BrickColor = BrickColor.Random() Bullet.Size = Vector3.new(7,7,7) Bullet.Shape = "Ball" Bullet.TopSurface = "Smooth" Bullet.BottomSurface = "Smooth" Bullet.CFrame = pistol.Handle.CFrame Bullet.CFrame = CFrame.new(Bullet.Position, mouse.Hit.p) Bullet.Touched:connect(function(touched) local humanoid = touched.Parent:findFirstChild("Humanoid") if humanoid and humanoid.Parent.Name ~= player.Name then humanoid:TakeDamage(25) Bullet:Destroy() end end) return Bullet end
pistol.Activated:connect(function() while wait() do bullet = makeBullet() local bodyVelocity = Instance.new("BodyVelocity", bullet) bodyVelocity.velocity = bullet.CFrame.lookVector * 200 bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) game.Debris:AddItem(bullet, 3) end end)
pistol.Deactivated :connect(function() bullet:Destroy() end)
|
|
|
| Report Abuse |
|
|