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 » Scripting Helpers
Home Search
 

Re: Raycasting

Previous Thread :: Next Thread 
MangoActual is not online. MangoActual
Joined: 04 Jul 2014
Total Posts: 152
01 Nov 2014 08:09 PM
I just finished reading the raycasting wiki and now I want to know how to make it emit from a part instead of your torso.
Help me?

Here is the script:

--settings
range = 999 --ray range
damage = 18 --ray damage
color = 'Bright yellow'
raytrans = 0 --ray color
--do not edit below!!

local tool = script.Parent
local char
tool.Equipped:connect(function(mouse)
char = tool.Parent
mouse.Button1Down:connect(function()
--Making things
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*range)
local hit, position = game.Workspace:FindPartOnRay(ray, char)
--Time to do damage
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(damage)
end
--Now making teh ray/bullet
local distance = (position - tool.Handle.CFrame.p).magnitude
local rayp = Instance.new('Part', char)
rayp.Name = 'rayp'
rayp.BrickColor = BrickColor.new(color)
rayp.Transparency = raytrans
rayp.Anchored = true
rayp.CanCollide = false
rayp.TopSurface = Enum.SurfaceType.Smooth
rayp.BottomSurface = Enum.SurfaceType.Smooth
rayp.formFactor = Enum.FormFactor.Custom
rayp.Size = Vector3.new(0.2, 0.2, distance)
rayp.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
---now to add to debris so it doesnt stay there!
game.Debris:AddItem(rayp, 0.1)
end)
end)


Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
01 Nov 2014 08:14 PM
Just replace 'tool.Handle.CFrame.p' with whatever position you'd like it to shoot from.
Report Abuse
MangoActual is not online. MangoActual
Joined: 04 Jul 2014
Total Posts: 152
01 Nov 2014 08:18 PM
So I have a part but there is two problems:

1)It shoots from where the part was placed, I think i need to weld it..
2)It only shoots once then stops
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
01 Nov 2014 08:18 PM
Put it in a local script.
Report Abuse
MangoActual is not online. MangoActual
Joined: 04 Jul 2014
Total Posts: 152
01 Nov 2014 08:35 PM
@God

I'm not stupid, this is already a local script.
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
01 Nov 2014 08:38 PM
SHUT THE FUCK UP!!!
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
01 Nov 2014 08:47 PM
The troll account is real.
Hey, I wonder if they'll give you an IP ban?
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
01 Nov 2014 08:49 PM
They already tried IP banning me.
XD

http://gyazo.com/26e61274b7541e27a8d5a31f2f888065
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
01 Nov 2014 08:50 PM
Is the giraffe okay?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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