I’m having issues with this. I’m not sure if I am doing something wrong but if I stand still and hit the same character it stops detecting the hits unless I move prior to hitting it.
local handle = script.Parent
local tool = handle.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
local newHitbox = RaycastHitbox.new(script.Parent)
local Params = RaycastParams.new()
local hitSound = handle:WaitForChild("Hit")
local swingSound = handle:WaitForChild("Swing")
local charDefined = false
tool.Equipped:Connect(function()
if not charDefined then
charDefined = true
Params.FilterDescendantsInstances = {tool.Parent}
Params.FilterType = Enum.RaycastFilterType.Exclude
newHitbox.RaycastParams = Params
end
end)
local deboucne = false
local turnOffAfterThisAmountOfSeconds = .25
tool.Activated:Connect(function()
if deboucne == false then
deboucne = true
swingSound:Play()
newHitbox:HitStart(turnOffAfterThisAmountOfSeconds)
tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(180),0,0)
task.wait(0.75)
tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(90),0,0)
task.wait(.25)
deboucne = false
end
end)
newHitbox.OnHit:Connect(function(hit, humanoid)
hitSound:Play()
print(hit)
humanoid:TakeDamage(1)
end)
robloxapp-20230618-2254499.wmv (1.9 MB)