When my raycast hits a accessory i get the character by going RayInst.Parent but the problem is if it hits an accessory the parent isnt the character its the accessory i have tried an if statement
if raycastResult.Instance.Name == "Handle" or raycastResult.Instance.Parent:IsA("Accessory") or raycastResult.Instance.Parent:IsA("Accoutrement") then
but the problem is that if the player has a big accessory on them, it will just straight up not hit them at all, i want the raycast to ignore accessories and find thats through the accessory
Personally I always just make the first accessory hit damage the player anyway, and then just set the accessory’s handle’s CanQuery to false in the same swoop. Obviously this isn’t perfect, but usually fits what I’m trying to do.
You can also listen to the CharacterAdded event and loop through a character’s children and set it then.
You can add a server script in the StarterCharacterScripts folder and disable the CanQuery option from the handle of each Accessory the player’s character has. If you have manually made the accessories then disable their CanQuery option already in the studio. Otherwise, the following script will automatically do so to Roblox ones.
local chr = script.Parent
local plrs = game:GetService("Players")
local plr = plrs:GetPlayerFromCharacter(chr)
repeat
wait()
until plr:HasAppearanceLoaded()
for i, v in pairs (chr:GetChildrent()) do
if v:IsA("Accessory") then
local hnd = v:FindFirstChild("Handle")
if hnd then
hnd.CanQuery = false
end
end
end