I’m looking to use the Raycast Hitbox module for my melee combat game, since the Touched event has proven to be unsuitable for my game considering the fast swings that the Touched event doesn’t register.
For some reason, the rays casted from the weapon lag behind whenever the player moves around, unlike the fluid rays that match with movement as shown on the official post for the module. Even in the example place provided for the module, the same issue happens with the sword tool. Here’s a few clips, the first one is my place and the second one is the example place:
https://i.gyazo.com/454ed144d558468f83be13fc93e68997.mp4
https://i.gyazo.com/8610e253c092fb43eabd4d8bbcfd9878.mp4
And here’s a chunk of my weapon code utilizing the module:
local RaycastHitbox = require(ServerScriptService.RaycastHitboxV4)
local hitbox = RaycastHitbox.new(weapon)
swingStarted.Event:Connect(function()
hitbox:HitStart()
end)
swingEnded.Event:Connect(function()
hitbox:HitStop()
end)
hitbox.OnHit:Connect(function(hit, humanoid)
-- Clone effects into hit body part
local effect = attackEffect:Clone()
effect.Parent = hit
effect.Enabled = true
local effect2 = attackEffect2:Clone()
effect2.Parent = hit
effect2.Enabled = true
-- Play hit sound
local rng = Random.new()
local sound = hitSound:Clone()
sound.Parent = hit
sound.PitchAdjust.Octave = rng:NextNumber(0.98, 1.1)
sound:Play()
-- Change outline color if there is an outline
if hit.Parent:FindFirstChild("TargetOutline") then
hit.Parent.TargetOutline.OutlineColor = Color3.fromRGB(255,255,255)
end
-- Damage target
humanoid:TakeDamage(baseDamage)
wait(0.1)
-- Destroy effects in hit body part
effect:Destroy()
effect2:Destroy()
-- Change outline color back if there is still an outline
if hit.Parent:FindFirstChild("TargetOutline") then
hit.Parent.TargetOutline.OutlineColor = Color3.fromRGB(255,0,0)
end
-- Wait for sound to end, then destroy the sound
wait(sound.TimeLength - 0.1)
sound:Destroy()
end)
I’ve tried changing around some basic settings in the module, as well as looking more into the code, but I can’t tell if it’s an issue with the module itself or my code. It seems that the module has worked perfectly fine for others, what can I do to fix this?