Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:07 PM |
local ray = Ray.new(script.Parent.Barrel.CFrame.p, (Find.Position - script.Parent.Barrel.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user)
local distance = (position - script.Parent.Barrel.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Brown") rayPart.Transparency = 0.4 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
They stop the ray when something is in their way D:
Please help fix this code. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 06 Jan 2015 10:09 PM |
| Try FindPartOnRayWithIgnoreList I think |
|
|
| Report Abuse |
|
|
Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:13 PM |
| I do not know much of ray casting, could you edit this?? Or tell me what to do? |
|
|
| Report Abuse |
|
|
Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:14 PM |
| Changing that made it not work at all. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Jan 2015 10:25 PM |
| The second argument should be a table containing everything you want to ignore |
|
|
| Report Abuse |
|
|
Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:26 PM |
I actually by surprise understood everything you said ;o
But, just how am I supposed to insert every single object except the enemies to ignore? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Jan 2015 10:31 PM |
| What are enemies in your case? Players on different teams or? |
|
|
| Report Abuse |
|
|
Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:34 PM |
This is the upper part I just added. The output says Unable to cast Object or something
function LookForPlayer() for i,v in pairs(game.Workspace:GetChildren()) do if v:FindFirstChild("Humanoid") then return v end end end
local player = LookForPlayer() local user = {user,player} |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Jan 2015 10:37 PM |
Why not just use this to get the first thing with a humanoid in it?
local humanoid = workspace:FindFirstChild("Humanoid", true); if humanoid then return humanoid.Parent; end |
|
|
| Report Abuse |
|
|
Crythox
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1188 |
|
|
| 06 Jan 2015 10:39 PM |
| Fixed it, thanks for your guys help c: |
|
|
| Report Abuse |
|
|