ClientCast - A Client-based, Idiosyncratic Hitbox System!

Whats the difference between this and RaycastHitboxV4

This module aims to provide easy client-server communication, unlike other modules which only handle hitboxes.

Sorry, If these already got answered above but

  1. What does it mean when you say client-server communication when it runs on the server?
  2. Does it only work on moving parts?

The client calculates the hitbox, and sends the result to the server. The server handles the actual hitbox logic, but behind the scenes its all calculated on the client (though you can set it to be server-only).

Correct. It raycasts from the previous to the current position, so if ||p1 - p0|| = 0, the raycast distance will also be 0.

1 Like

How safe is it to calculate everything on the client?
also fi the player ping is high, should I cast on the server?

Hello Just want to notify you there is a new update for raycast.
Will you update your module or no ?

No, because shapecasts are more expensive and dont solve the issue of raycasting between gaps like so:
image
Since raycasts are lines, they can perfectly raycast from the start to the end, with fidelity and precision being configurable with the amount of damage points you set.

1 Like

I’m getting a strange bug where object is not being replicated - i tracked it to here. Can you check it?



I can’t do much with this info, I need a place file which reproduces the issue in as few lines as possible. Are you sure you’re passing an Instance to the first argument of ClientCast.new though?

exampleOfProblem.rbxl (58.4 KB)
I don’t think the problem is me because in your code it prints the object

1 Like

It seems like the issue is related to Roblox replication - the local client’s own character seems to not have replicated in time to the client, so when the server sends a remote with the character as the owner, the client doesn’t recognize the object as it doesnt yet exist on its side.
I’ve been able to fix it by adding task.wait(2) before creating the caster, but in general you should try creating the caster on-demand, and only re-use the caster after it was created the first time.

1 Like

is there anyway I can visualize the rays on a single client?

Hello, I am currently using this module to detect collision. However, I added a section in my script to check the distance between the target and the caster. In my case it’s 14 Studs. I added this checker to account for the delay between server and client and exploiters.

The issue is that when an enemy is large and is further away from the caster, it won’t deal damage. Does anyone have any solution to this problem?

This is a video I made earlier when I thought the issue was from client cast not detecting other parts from a character

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.

1 Like

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

1 Like

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

1 Like