#hitbox not moving

1 messages · Page 1 of 1 (latest)

dapper bronze
#
local RE = game.ReplicatedStorage.HitEvent
local canDamage = true

function onTouch(otherPart)
    local hum = otherPart.Parent:FindFirstChild("Humanoid")
    if hum then
        if canDamage == true then
            canDamage = false
            hum.Health = hum.Health - 15
            task.wait(0.4)
            canDamage = true
        end
    end
end




RE.OnServerEvent:Connect(function(player, hitbox)
    local hum = player.Character:FindFirstChild("Humanoid")
    hitbox.Parent = workspace
    local motor = Instance.new("Motor6D")
    motor.Part0 = hitbox
    motor.Part1 = player.Character:FindFirstChild("Torso")
    hitbox.CFrame = player.Character:FindFirstChild("Torso").CFrame + Vector3.new(0, 0, -4)
    task.wait(0.2)
    hitbox.Parent = game.ReplicatedStorage
end)

hitbox.Touched:Connect(onTouch)```

I want it so the hitbox moves with the torso, meaning if i look back it'll do the hitbox normally infront of me, NOT BACKWARDS.
#

@vernal bay can you help

#

or

#

?

#

btw i tried normal weld, weld constraint and motor6d and it still doesnt work

vernal bay
#

what's wrong with what you have now?

dapper bronze
#

it works perfectly normal

#

but when i look backwards and do hitbox

#

the hitbox is behind me now

vernal bay
#

ah

#

i see why

#

you're doing this in worldspace

dapper bronze
#

so uh

#

OH

vernal bay
#

its not gonna be relative to the torso

#

its gonna be relative to the world

dapper bronze
#

DO I NEED TO MAKE A NEW HITBOX

#

??????

#

from the scirpt

vernal bay
#

no

dapper bronze
#

itself

vernal bay
#

hitbox itself is fine

#

it has to be relative to the torso's forward position

dapper bronze
#

howdoidothat

vernal bay
#

plenty of ways

#

there is CFrame:ToObjectSpace()

#

welds

#

etc

dapper bronze
#

!!

#

@vernal bay what do i do

vernal bay
#

one moment

dapper bronze
#

ok

vernal bay
#

instead of this