#Blacklisting a character from a raycast

1 messages · Page 1 of 1 (latest)

leaden quarry
#

I have a raycast but I don't want it to collide with player's character. I know how to get all parts of a character for blacklisting, but I'm unsure on whether I should use a local script in the StarterPlayerScripts, or a Module script.

native void
#

Use module script

#

Use raycastparams

#

Filter the char

#

Filter type to exclude

leaden quarry
#

should i also make the mousepart thing apart of the module script since i would be requiring that the raycast params be equal to the table in the module script?

leaden quarry
shell aspenBOT
#

studio** You are now Level 4! **studio

leaden quarry
#

"Attempted to call require with invalid arguments"

native void
#

Why are you requiring the server storage and blacklist for the filter descendants ☠️

#

I thought you want to exclude char

#

Btw it's exclude not blacklist

#

Blacklist is deprecated

#

U use AI or smth?

leaden quarry
leaden quarry
#

this is literally my first day scripting

#

im not even familiar with all of the tabs im just moving scripts around to see which one they will work in

native void
#

In Ur first day of scripting I don't recommend you to learn raycasting

#

You should learn something else like tweenservice

#

But it's fine

leaden quarry
leaden quarry
#

the thing is im trying to make it so this raycast doesnt hit the player (the dot represents where the raycast collides)

#

i just dont want the player to be hit by the raycast so the dot doesnt collide with them, meaning i'll have to blacklist the player

native void
#

So did you fix it?

leaden quarry
#

so far, the module scripts dont even seem to be firing when required

#

and idk why

native void
#

Which origin your raycasting from

#

The mouse?

leaden quarry
#

im ngl i snagged this from a video lol

leaden quarry
#

everything works fine aside from the fact that the raycast stops at the player

native void
#

Try printing raycastresult

#

See what you get

leaden quarry
#

i do print "raycast hit" when the raycast hits somethingf

#

like when i put mouse over player

#

so i can guarantee the player is getting hit

leaden quarry
native void
#

Printing raycast hit doesn't guarantee you hit the player, printing raycastresult let you know which object you hit

#

More specific

leaden quarry
#

ah

#

alrighty then

native void
#

Wait no it's raycastresult.instance

#

Not just raycastresult srry lol

leaden quarry
native void
#

What did it print?

leaden quarry
#

as expected, it is colliding with the character

native void
#

Lemme see you raycast params again

native void
#

Dude it's filter descendants char

#

Not mouse

leaden quarry
#

whats that mean

native void
#

Filter the character

#

Not the mouse

leaden quarry
#

is it unable to do both? will it only filter one and not the other?

native void
#

Yeah it can filter a lot but why need to filter mouse?

leaden quarry
#

also then how would i get a character, which would typically be gotten by looping through all descendants of said character. characteradded fails to run in local script

native void
#

It won't hit the mouse

leaden quarry
native void
leaden quarry
# leaden quarry the video i watched said that it needed to filter the mouse so it doesnt fly tow...

In this tutorial, I show and explain how to get and use the mouse position to use in your Roblox creations! In this video, I show two methods, one using ray casts and the other using the mouse obj. If you have any questions regarding the series or Roblox Studio in general, join the Discord server: https://discord.gg/xJB2Adu4cr! Make sure to subs...

▶ Play video
#

17 minutes 53 seconds in

leaden quarry
#

srry if im being a dumbass btw😭

native void
#

Ur doing the raycast in module of local

#

Or

leaden quarry
#

cuz like

#

rn

#

my only 2 issues are

  1. getting all of the player base parts into a module script
  2. requiring a module script so that i can link it to the local script so that everything in the module script is blacklisted
native void
#
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")

local Char = Player.Character or Player.CharacterAdded:Wait()

local params = RaycastParams.new()
params.FilterDescendantsInstances = {Char}
params.FilterType = Enum.RaycastFilterType.Exclude

RunService.Heartbeat:Connect(function()
    local Mouse = Player:GetMouse()
    local UnitRay = Mouse.UnitRay

    local origin = UnitRay.Origin
    local direction = UnitRay.Direction * 10000

    local result = workspace:Raycast(origin, direction, params)

    if result then
        print(result.Instance)
    else
        print("No hit")
    end
end)
#

enter this into ur local script

#

make a new one

native void
#

ye

#

np

#

now u know how raycast work right?

shell aspenBOT
#

studio** You are now Level 10! **studio

leaden quarry
#

wait gimme a sec to study this real quick

#

yeah alright i understand the script now

shell aspenBOT
#

studio** You are now Level 5! **studio

leaden quarry
#

tysm