Okay nvm, I figured it out. I would just use the Resulting Part that the raycast hit and use that position instead of the humanoid root parts position to figure out the distance between the target and caster.
With this module I havenāt had any issues until I went to test the actual swinging. After spam clicking the attack the hitboxes just sort of lag out the game and break. This is unusual since itās not like thereās not a cooldown, there is one that lasts for 0.5 seconds. This only happens whenever I set the hitbox owner to the player for accurate hitboxes. Is there anyway to fix this? Also I know for a fact that the hitbox isnāt being spammed as long as the cooldown is on since it has to go through both a server and a client cooldown for it to activate. Also printed it to make sure. [UPDATE]: I fixed it but only by switching to the June 3, 2022 build of ClientCast. Pretty weird.
Hereās the code since I cannot figure this out at all:
--//Modules
local VFXModule = require(game:GetService("ServerStorage").Modules.VFXModule)
local CombatModule = require(game:GetService("ServerStorage").Modules.CombatModule)
local CraterModule = require(game:GetService("ServerStorage").Modules.CraterModule)
local clientCast = require(game:GetService("ServerStorage"):WaitForChild("Modules"):WaitForChild("ClientCast"))
--//Variables
local tool = script.Parent.Parent.Parent; local handle = tool:WaitForChild("Handle")
local remote = script.Parent.Parent:WaitForChild("Remotes"):WaitForChild("Click")
local cdList = {}
--//Properties
local properties = {
["Damage"] = 15,
["HitboxDuration"] = .3,
["Stun"] = 1,
["Cooldown"] = .5,
["Endlag"] = .4,
}
local animations = {
"13797575179",
"13797575179",
}
remote.OnServerEvent:Connect(function(player, animOrder)
if cdList[player.Character] then return end
cdList[player.Character] = true
task.delay(properties.Cooldown -.1, function()
cdList[player.Character] = nil
end)
--//Windup
VFXModule.playSound(player.Character.HumanoidRootPart, 6241709963, .5, 2)
VFXModule.playAnim(player.Character.Humanoid, animations[animOrder])
CombatModule.busy(player.Character, properties.Endlag)
--hb
local hitList = {}
local hitCast = clientCast.new(handle, RaycastParams.new())
hitCast.HumanoidCollided:Connect(function(result, hum)
local victim = hum.Parent
if hitList[victim] or victim == player.Character then return end
hitList[victim] = true
--//Event
CombatModule.damage(player, victim, properties.Damage)
CombatModule.stun(victim, properties.Endlag)
VFXModule.playSound(victim.HumanoidRootPart, 5473058688, .5, 2)
VFXModule.playSound(victim.HumanoidRootPart, 1158092528, .5, 2)
VFXModule.spawn(victim, game:GetService("ReplicatedStorage").VFX.BloodVFX, 50)
end)
hitCast:SetOwner(player)
hitCast:Start()
task.wait(properties.HitboxDuration)
hitCast:Stop()
end)
By the way this ONLY happens in the actual game and not studio
Just so you know if you use CasterInstance:SetOwner()
the debug mode breaks, causing both the ClientCast module and ClientHandler localscript to create their own debug trails and attachments. The ClientCast modules debug trails also never update causing them to always show no matter the state of the cast instance.
does it have a blacklist of what part should be ignored?
You can add RaycastParams in the .new() function
ouh i forgot about that bruh and did it fire an event once?
No it doesnāt fire event once but every time it hit so you ha e to make ur own HitTable
Is it better to use ClientCast on the server side or on the client side?
If you use it on the client side, itās too hard to calculate on the server side, and if you donāt do the calculation, the hitbox will be detected even when youāre too far away.
Conversely, if you use it server-side, the hit result will be strange because of the large delay.
I think the client side is better, but I present a problem because the calculation is difficult and may not be accurate.
Personally Iāve always done client-sided calculation for melee hitboxes, because players can still teleport themselves right up to another player, achieving the same serverside bypass regardless; speed/teleport anticheats wouldnt work on short distances either.
Iām having an issue when I set the owner of the raycast the HumanoidCollided function just completely stops working. Any suggestions?
easy fix i just used the regular .collided and checked for the humanoid there
Does ClientCast have a function similar to SetPoints Function that creates Points like RaycastHitboxV4?
ReplicatedStorage.Framework.ClientCast:115: attempt to index nil with āDisabledā How do I fix this error?
Why should I use this instead of RaycastHitbox?
RaycastHitbox was DESIGNED for use on the server only. Clientcast has a more ergonomic type of use that benefits any network owner, and lets you detect hits on the server with client sided hitboxes automatically, etc.
RayCast Hitbox initially was made for server sided use, now its recommended to use client-side as the module has improved a lot since then and the client runs at a smoother 60hz compared to the servers ~15hz
So wait, what even is the point of using clientcast then? You can use raycasthitbox from localscripts and stuffā¦
also where is this stated?
the creator replied to a person who was talking about delay/lag with the ray casts because he is using the server, You could probably find it somewhere under the comments of the post.
also Iām not familiar with client cast so I donāt know the differences etc