|
| 05 Jul 2016 12:20 AM |
change the barrel1 to whatever you want the laser to originate from.
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!") 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("Bright blue") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0.25 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (tool.Barrel1.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3, 0.3, distance) beam.CFrame = CFrame.new(tool.Barrel1.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) game:GetService("Debris"):AddItem(beam, 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(30) end end end) end)
|
|
|
| Report Abuse |
|
|
CowInAJar
|
  |
| Joined: 27 Jun 2012 |
| Total Posts: 65 |
|
|
| 05 Jul 2016 12:31 AM |
| Why did you just copy and paste the raycasting tutorial? |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 12:35 AM |
| so many people don't know. |
|
|
| Report Abuse |
|
|
CowInAJar
|
  |
| Joined: 27 Jun 2012 |
| Total Posts: 65 |
|
|
| 05 Jul 2016 12:38 AM |
You could've just linked to the wiki...
\\ |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 05 Jul 2016 01:07 AM |
| Or you could have avoided creating this thread altogether. |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Jul 2016 02:11 AM |
Everyone here knows how. The only people that don't know how would create a thread, asking how to do it. This thread is pointless
|
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 03:05 AM |
| Challenge: Add degrees spread |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 12:08 PM |
i modified it making it look cool :^
besides that this is done. |
|
|
| Report Abuse |
|
|
Cinnace
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 370 |
|
|
| 05 Jul 2016 12:18 PM |
https://www.roblox.com/games/438821549/Scripting-demo
or this
- Cinnace |
|
|
| Report Abuse |
|
|