|
| 01 Jan 2015 01:02 PM |
local t = script.Parent
t.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local ray = Ray.new (t.Handle.CFrame.p, (mouse.Hit.p - t.Handle.CFrame.p).unit*500) local ignore = game.Workspace.Ground.Wheat local hit, position = game.Workspace:FindPartOnRay(ray, ignore) if mouse.Target ~= nil then if hit.Name == "Ground" then print("IT WORKS") end end end) end)
This is a script that if you click a part called "ground", it gonna print "IT WORKS". It really works and it print that message when i click that block. But.... this is the first time i use raycast and i dont know how use the ignore list. The part called "wheat" must be ignored and you can click the part named "Ground" through it. But it doesnt work. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 01:04 PM |
| Sorry for posting this again but the last post i bumped like 10 times ._. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 01:13 PM |
| You guy JUST, JUST need to help me making that the brick wheat is an ignorable part. So we can click through and select the ground part. Its not hard :I |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2015 01:22 PM |
| i dont know how apply the "ignore" list anyone can tell me? |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 01:29 PM |
| If nobody replies me that means the script i am making is REALLY REALLY REALLY REALLY REALLY REALLY hard to build ._. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 01 Jan 2015 01:43 PM |
Wait, wheat is inside ground? Is ground a model or a part? Also, your code assumes that if mouse.Target exists, hit must exist. That's not necessarily true because mouse.Target doesn't exclude wheat, whereas the raycast does. Other than that, it looks fine.
local ignore = workspace.Wheat t.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local ray = Ray.new (t.Handle.CFrame.p, (mouse.Hit.p - t.Handle.CFrame.p).unit*500) local hit, position = workspace:FindPartOnRay(ray, ignore) if hit and hit.Name == "Ground" then print("IT WORKS") end end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2015 01:46 PM |
getWheat =function(f) local ret ={}; for a,b in next,f:children'' do if(b.Name=='Wheat') then table.insert(ret,b); end; end; return ret; end;
local t = script.Parent
t.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local ray = Ray.new (t.Handle.CFrame.p, (mouse.Hit.p - t.Handle.CFrame.p).unit*500) local ignore = getWheat(workspace.Ground); local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignore) if mouse.Target ~= nil then if hit.Name == "Ground" then print("IT WORKS") end end end) end) |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 01:48 PM |
oops, didn't notice this before I posted... The ray might also collide with the handle, so you may want to write something like this:
workspace:FindPartOnRayWithExclusionList(ray, {ignore, t.Handle}) |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2015 02:02 PM |
| Wait, mine didn't work, master? |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2015 02:31 PM |
This should help you debug...
local ignore = {t.Handle, workspace.Ground.Wheat} t.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local ray = Ray.new (t.Handle.CFrame.p, (mouse.Hit.p - t.Handle.CFrame.p).unit*500) local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, ignore) if hit then print("Ray intersected with ", hit.Name) else print("No part intersect with ray") end end) end) |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 04:46 PM |
| when i click the wheat it prints No intersected with ray |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 04:49 PM |
| Wait, it works weirdly... Sometimes when i click through the wheat it says Ray intersected by Right Arm, Ray intersected by Torso... without clicking my character ._. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 04:52 PM |
| Everything works except the direction of the ray... |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 04:56 PM |
wait... I KNOW WHY IT DOESNT WORK...!
How do i add all body parts of the character in the ignored list? |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 01 Jan 2015 04:57 PM |
| just put the character model in the ignore list |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 05:05 PM |
Yep, it works weirdly when i click the Wheat. When i click on it, the ray changes its direction.
I made this:
Instance.new("Part",game.Workspace).Position = position
When i click through the wheat, the brick spawns randomly anywhere |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2015 05:11 PM |
| Its something similar when a light pass through a glass and changes its direcction |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2015 05:49 PM |
Ohh i know whats happening...
Its hard to explain... The part "Wheat" ignore the ray, BUT if you click on it it will change the direction... |
|
|
| Report Abuse |
|
|