#Sometimes the hitbox hits, sometimes it doesnt

1 messages · Page 1 of 1 (latest)

tawny berry
#

script: local swordEvent = game.ReplicatedStorage.swordEvent
local db = true
local debounceTime = 0.4

swordEvent.OnServerEvent:Connect(function(plr, hit)
if not db then return end
db = false

delay(debounceTime, function()
    db = true
end)

if hit then
    if hit.Parent:FindFirstChild("Humanoid") then
    hit.Parent.Humanoid:TakeDamage(15)
    print(hit)
    end
    end


if hit.Parent:FindFirstChild("HumanoidRootPart") then
    local stabbed = game.ReplicatedStorage.Sfx["Stab Splat Shorter"]
    local clone = stabbed:Clone()
    clone.Parent = hit.Parent.HumanoidRootPart
    clone:Play()
end

end)

gleaming nebula
#

You haven't sent all the code

#

Also, the code you have sent, is missing sanity checks. An exploiter could fire that event with whatever character they wanted

eternal lintel
#

It looks like something in code you aren’t showing us is only registering hits on the torso/hrp

kind skiff
#

Holy shit you’re cooked

tawny berry
#

Mb

#

--Combat
local m1 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m1)
m1.Priority = Enum.AnimationPriority.Action

local m2 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m2)
m2.Priority = Enum.AnimationPriority.Action

local m3 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m3)
m3.Priority = Enum.AnimationPriority.Action

local combo = 1

function hitbox()
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Massless = true
hitbox.Anchored = false
hitbox.CFrame = blade.CFrame
hitbox.Color = Color3.new(3, 0, 0)
hitbox.Material = Enum.Material.Wood
hitbox.Transparency = 0.5
hitbox.Size = Vector3.new(2, 6, 2)

local weld = Instance.new("WeldConstraint")
weld.Parent = hitbox
weld.Part0 = hitbox
weld.Part1 = blade

game.Debris:AddItem(hitbox, 0.7)



--fire to server!

hitbox.Touched:Connect(function(hit)

game.ReplicatedStorage.swordEvent:FireServer(hit)
end)

end

local db = true -- debounce variable
local debounceTime = 0.6 -- seconds

tool.Activated:Connect(function()
if not db then return end
db = false

delay(debounceTime, function()
    db = true
end)

if combo == 3 then
    hitbox()
    m3:Play()
    sound1:Play()
    print("Third M1")
    wait(1)
    combo = 1
elseif combo == 2 then
    hitbox()
    m2:Play()
    sound1:Play()
    print("Second M1")
    combo = combo + 1
elseif combo == 1 then
    hitbox()
    m1:Play()
    print("First M1")
    sound1:Play()
    combo = combo + 1
end

end)

#

all variables are listed alr, the message wass too long

#

@gleaming nebula @eternal lintel

gleaming nebula
#

You should do a spatial query every frame instead

tawny berry
#

so heartbeat?

#

@gleaming nebula

#

can i use getpartsinpart

gleaming nebula
gleaming nebula
tawny berry
#

Ok

tawny berry
#

Fixed

#

used a clone of a hitbox