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: A question about a more accurate explosion.

Previous Thread :: Next Thread 
ozza is not online. ozza
Joined: 11 Oct 2007
Total Posts: 726
29 Apr 2012 02:52 PM
local Tool = script.Parent
local User
Tool.Equipped:connect(function(mouse)
User = Tool.Parent
mouse.Button1Down:connect(function()
if script.Parent.Ammo.Value > 0 then
local Ray = Ray.new(Tool.Handle.CFrame.p,(mouse.Hit.p-Tool.Handle.CFrame.p).unit*300)
local Hit,Position = game.Workspace:FindPartOnRay(Ray,User)
if Hit then
expl = Instance.new("Explosion")
expl.Parent = Workspace
expl.Position = Hit.Position
if Hit.Parent:FindFirstChild("Humanoid") then
Hit.Parent.Humanoid:TakeDamage(30)

end
end
local RayPart = Instance.new("Part",User)
RayPart.Name = "RayPart"
RayPart.BrickColor = BrickColor.new("Bright yellow")
RayPart.Transparency = 0
RayPart.Anchored = true
RayPart.CanCollide = false
RayPart.TopSurface = Enum.SurfaceType.Smooth
RayPart.BottomSurface = Enum.SurfaceType.Smooth
RayPart.formFactor = Enum.FormFactor.Custom
local Distance = (Position-Tool.Handle.CFrame.p).magnitude
RayPart.Size = Vector3.new(0.2,0.2,Distance)
RayPart.CFrame = CFrame.new(Position,Tool.Handle.CFrame.p) * CFrame.new(0,0,-Distance/2) --Move it halfway.
game.Debris:AddItem(RayPart,0.1) --Add it to the debris.
script.Parent.Ammo.Value = script.Parent.Ammo.Value-1
end

end)
end)


So I have this code, which is in my gun, but my question is, for the explosion is there a way to make it spawn DIRECTLY where the ray hit?

- Ozza -
Report Abuse
ozza is not online. ozza
Joined: 11 Oct 2007
Total Posts: 726
29 Apr 2012 03:25 PM
Anyone?

- Ozza -
Report Abuse
grantox is not online. grantox
Joined: 26 Nov 2010
Total Posts: 2314
29 Apr 2012 04:01 PM
Well i don't know about directly where it hit, but you could center it on the brick or piece of terrain it hit. but i don't know didly squat about scripting ;)
Report Abuse
ozza is not online. ozza
Joined: 11 Oct 2007
Total Posts: 726
29 Apr 2012 04:13 PM
The point is it already does that.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
29 Apr 2012 04:16 PM
I guess you could use the ClosestPoint method of the Ray...
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
29 Apr 2012 04:17 PM
wait...

Doesn't the FindPartOnRay method also give you the position?
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