Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

melee hitbox positioning when moving?

Asked by 2 years ago
Edited 2 years ago

when standing still the hitbox position looks like this. https://drive.google.com/file/d/1aNqOV_hZfGfNhj3lKzYWiDFXwfSW5k9w/view?usp=sharing

but when the character is moving the hitbox looks like this. https://drive.google.com/file/d/1zK92Rtbtzlgfe8eTIp9yBP6AJzMDmWpj/view?usp=sharing

is there any way to position the hitbox so that when moving the hitbox looks like the one when standing still?

local function makeRay(origin2, target, show)
    local origin = origin2+(char.HumanoidRootPart.CFrame.LookVector*1)
    local raycastParams = RaycastParams.new()
    raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
    raycastParams.FilterDescendantsInstances = plrs
    local raycastResult = workspace:Raycast(origin, target, raycastParams)
    if raycastResult then   
        if raycastResult.Instance.Parent:FindFirstChild("Humanoid") and raycastResult.Instance.Parent:FindFirstChild("HumanoidRootPart") then
            local victim = raycastResult.Instance.Parent
            local isIn = false
            for i, v in ipairs(hitPlr) do
                if v == victim then
                    isIn = true
                end
            end
            if isIn == false then
                table.insert(hitPlr, victim)
                victim.Humanoid:TakeDamage(damage)
            end
        end
    end
end
local hrp = char.HumanoidRootPart
makeRay(hrp.Position, (hrp.CFrame.LookVector)*range, true)

Answer this question