generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: working laser gun script (Straight from wiki)

Previous Thread :: Next Thread 
ninjabeast0117 is not online. ninjabeast0117
Joined: 19 Dec 2011
Total Posts: 489
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 is not online. 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
ninjabeast0117 is not online. ninjabeast0117
Joined: 19 Dec 2011
Total Posts: 489
05 Jul 2016 12:35 AM
so many people don't know.
Report Abuse
CowInAJar is not online. 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 is not online. 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
Justin_Trill is not online. Justin_Trill
Joined: 28 Aug 2014
Total Posts: 636
05 Jul 2016 02:09 AM
^


Report Abuse
Protoduction is not online. Protoduction
Joined: 27 Jul 2012
Total Posts: 1054
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
RegularTetragon is not online. RegularTetragon
Joined: 10 Oct 2009
Total Posts: 3085
05 Jul 2016 03:05 AM
Challenge: Add degrees spread
Report Abuse
ninjabeast0117 is not online. ninjabeast0117
Joined: 19 Dec 2011
Total Posts: 489
05 Jul 2016 12:08 PM
i modified it making it look cool :^

besides that this is done.
Report Abuse
Cinnace is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image