I’m attempting to get the parts from the server position of what is being hit by the sword.
This is what I have but it isn’t actually detecting the parts in their proper position:
if Player == game.Players:GetPlayerFromCharacter(Character) then
local Sword = Tool.Handle
local SwordParts = 0
for _,Parts in pairs(Sword:GetDescendants()) do
if Parts:IsA("BasePart") then
SwordParts = SwordParts + 1
end
end
if Player then
local RayCasted = Ray.new(Sword.Attachment0.Position, (Sword.Attachment0.Position - Sword.Attachment1.Position))
print(RayCasted)
--if not RayCasted == nil then print(RayCasted) end
local Hit_Parts = GetAllParts(RayCasted, Sword)
--local Hit_Parts = Sword:GetTouchingParts()
if #Hit_Parts > SwordParts and Settings.Core_Options.RoClansEnabled.Value == true then -- This technically already includes arm.
for _,Hit in pairs(Hit_Parts) do
if not Hit:IsDescendantOf(Tool) and not Hit:IsDescendantOf(Character) and Hit.Name ~= "HumanoidRootPart" then
if Hit.Parent:FindFirstChild("Humanoid") then
local Hit_Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
local PassForDamage = CheckIfPasses(Player, Hit_Player, Character)
if PassForDamage == true then DamageCalculation(Player, Hit.Parent, Tool.Damage.Value, Tool, Hit) end
end
end
end
end
end
end
The GetAllParts function is this:
local function GetAllParts(Hit, Sword)
local Parts = {Sword}
local LastPart
if Hit ~= nil then
repeat
LastPart = workspace:FindPartOnRayWithIgnoreList(Hit, Parts)
table.insert(Parts, LastPart)
until LastPart == nil
end
return Parts
end
I’m not sure exactly why but it isn’t showing the parts that are being hit. I’ve been at this for almost 2 days now.