local part = script.Parent
local badpart = game.Workspace.shit
while true do
wait(1)
raypar = RaycastParams.new()
raypar.FilterDescendantsInstances = workspace.shit
raypar.FilterType = Enum.RaycastFilterType.Blacklist
local origin = part.Position
local direction = part.CFrame.LookVector * 100
local result = workspace:Raycast(origin, direction, raypar)
if result then
print(result.Instance.Name)
end
if not result then
print("nothing")
end
end
✓ ANSWER ACCEPTED
I need help, it just says "Unable to cast value to Objects". But why?
1 answer
✓ Accepted answer
##Problem:
You forgot to introduce the curly braces, which look like this {} on line 6 where it says workspace.Part.
The reason it didn't work is because the script thinks that you're trying to set the value, which in this case is raypart to an object, which is the part, remember that FilteringStrings are arrays.(tables)
##Solution:
Add the curly braces on line 06.
##Fixed Code:
local part = script.Parent
local badpart = game.Workspace.shit
while true do
wait(1)
raypar = RaycastParams.new()
raypar.FilterDescendantsInstances = {workspace.shit}
raypar.FilterType = Enum.RaycastFilterType.Blacklist
local origin = part.Position
local direction = part.CFrame.LookVector * 100
local result = workspace:Raycast(origin, direction, raypar)
if result then
print(result.Instance.Name)
end
if not result then
print("nothing")
end
end
Read the developer forums on :RayCastParams
##Resources:
1 comment
0
This is off-topic but don't name your stuff inappropriately.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Put your code in a code block for it to be easier to read and don't put inappropriate words in your code
Formatted the code
Whats the exact error? Which line of code fails?