So I’m trying to make hit detection for my fist-fighting game by placing parts at the end of the arm with wleds. My issue is that whenever I move the parts for some reason are in the wrong position and they follow a wierd pattern
Basically when you move but click while stopped it is behind the hand and when you click while you’re moving they go to opposite position (I think). I have searched for a solution on the devforum and google but couldn’t find anything that works.
My code:
local function createhit(hand : string)
local Dhitpart = Instance.new("Part")
Dhitpart.BrickColor = BrickColor.new("Tr. Red")
Dhitpart.Size = Vector3.new(char[hand].Size.X, 0.2, char[hand].Size.Z)
Dhitpart.Transparency = 0.2
Dhitpart.CanCollide = false
Dhitpart.Massless = true
local Lhitpart = Instance.new("Part")
Lhitpart.BrickColor = BrickColor.new("Lime green")
Lhitpart.Size = Vector3.new(Dhitpart.Size.X/2, 0.2, Dhitpart.Size.Z/2)
Lhitpart.Transparency = 0.2
Lhitpart.CanCollide = false
Lhitpart.Massless = true
local Dweld = Instance.new("Weld")
Dweld.C0 = CFrame.new(Dhitpart.CFrame.LookVector * 0.1)
Dweld.C1 = CFrame.new(Vector3.new(-Lhitpart.Size.X + Lhitpart.Size.X, Lhitpart.Size.Y/2, -Lhitpart.Size.Z + Lhitpart.Size.Z))
Dweld.Part0 = Dhitpart
Dweld.Part1 = Lhitpart
Dweld.Parent = Dhitpart
local weld = Instance.new("Weld")
weld.C0 = CFrame.new(char[hand].CFrame.LookVector * char[hand].Size.Y/2)
weld.C1 = CFrame.new(Vector3.new(-Dhitpart.Size.X + Dhitpart.Size.X, Dhitpart.Size.Y + Dhitpart.Size.Y/2 + 0.7, -Dhitpart.Size.Z))
weld.Part0 = char[hand]
weld.Part1 = Dhitpart
weld.Parent = char
Dhitpart.Parent = char
Lhitpart.Parent = Dhitpart
debris:AddItem(Dhitpart, 5)
debris:AddItem(weld, 5)
end