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 » Scripters
Home Search
 

Re: Ignore raycast problem!

Previous Thread :: Next Thread 
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:04 PM
Sorry for posting this again but the last post i bumped like 10 times ._.
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:14 PM
guys*
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:22 PM
i dont know how apply the "ignore" list anyone can tell me?
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:36 PM
Le bump
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:42 PM
bump
Report Abuse
SuperAlpacaMan is not online. SuperAlpacaMan
Joined: 18 Nov 2008
Total Posts: 774
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:45 PM
Wheat is inside ground
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
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
SuperAlpacaMan is not online. SuperAlpacaMan
Joined: 18 Nov 2008
Total Posts: 774
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 01:59 PM
Still not working :(
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
01 Jan 2015 02:02 PM
Wait, mine didn't work, master?
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 02:23 PM
no
Report Abuse
SuperAlpacaMan is not online. SuperAlpacaMan
Joined: 18 Nov 2008
Total Posts: 774
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 04:46 PM
when i click the wheat it prints No intersected with ray
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 04:52 PM
Everything works except the direction of the ray...
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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 is not online. 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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 05:11 PM
Its something similar when a light pass through a glass and changes its direcction
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
01 Jan 2015 05:30 PM
Can someone solve this?
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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