ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 26 Apr 2013 08:04 PM |
local tool = script.Parent local user
tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() 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) local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(7) end local distance = (position - tool.Handle.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("White") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(rayPart, 0.1) end) end) |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
| |
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
| |
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 12:11 PM |
1. For some reason, it only works in LocalScript. 2. It doesn't hurt the humanoid. |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
| |
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 12:19 PM |
When I use LocalScript, it doesn't damage the humanoid.
When I use Script, it damages humanoid, but ray is not drawn. |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 27 Apr 2013 12:20 PM |
| Try to make it cast more damage to the humanoid. |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 12:21 PM |
| What would that do? I tried it in build mode to monitor the Humanoid's health and it didn't go down at all. |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 27 Apr 2013 12:22 PM |
| Try putting elses and prints around "if" statements. |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 02:21 PM |
I said if the humanoid was hurt, print "Humanoid hurt!"
It printed, but it didn't work. |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
| |
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 27 Apr 2013 03:23 PM |
I looked in the wiki for raycasting guns too and I found out :TakeDamage() might not work, so I changed it to humanoid.Health = humanoid.Health - 7
That did work |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 03:26 PM |
| Bump again, someone please help. |
|
|
| Report Abuse |
|
|
ForceSky
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 2379 |
|
|
| 27 Apr 2013 03:28 PM |
| Ok, that's actually a good idea because I'm making a training area for my group. |
|
|
| Report Abuse |
|
|