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: Raycast [HELP]

Previous Thread :: Next Thread 
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 07:43 AM
So I just started a new thread because I should've just gave the whole code in the other one.

So I need the beam to go straight and out of the part "bang" and not follow the mouse. Help?

code:

Mouse.Button1Down:connect(function()
print("Mouse pressed!")
local ray = Ray.new(Main.Bang.CFrame.p, (Mouse.Hit.p - Main.Bang.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 red")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.25
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false

local distance = (Main.Bang.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(Main.Bang.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)

game:GetService("Debris"):AddItem(beam, 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(Damage)
end
end
end)
Report Abuse
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 08:29 AM
b1
Report Abuse
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 09:28 AM
b2
Report Abuse
YourWillPower is not online. YourWillPower
Joined: 14 Jul 2014
Total Posts: 535
02 Feb 2017 10:28 AM
b3
Report Abuse
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 12:21 PM
dang no one knows?
Report Abuse
SwagCuzYolo is not online. SwagCuzYolo
Joined: 31 Oct 2013
Total Posts: 1224
02 Feb 2017 12:52 PM
local ray = Ray.new(Main.Bang.CFrame.p, (Main.Bang.CFrame.lookVector*50 - Main.Bang.CFrame.p).unit * 300)
Report Abuse
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 01:07 PM
that makes the beam just go in 1 place.
Report Abuse
SwagCuzYolo is not online. SwagCuzYolo
Joined: 31 Oct 2013
Total Posts: 1224
02 Feb 2017 01:10 PM
local target = (Main.Bang.Position + Main.Bang.CFrame.lookVector*50)
local ray = Ray.new(Main.Bang.CFrame.p, (Target - Main.Bang.CFrame.p).unit * 300)
Report Abuse
GabrielHinez is not online. GabrielHinez
Joined: 09 Dec 2011
Total Posts: 455
02 Feb 2017 01:16 PM
it works, thanks!
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