All good, I’m not sure how to fix it so I will wait for you to push a fix. I msut use resetplayerguionspawn because I have important guis that need to be resetted when respawned. Nice one on noticing the bug so fast haha
Hey! The issue should now be fixed on GitHub, though I’m reworking ClientCast a bit to support Rojo, along with adding a brand new documentation API so I won’t update the devforum thread for a bit.
You can get the newest update here for now:
https://github.com/PysephWasntAvailable/ClientCast
(cc. @Downrest, your issue should also be fixed now)
Update 1.10.0
- Completely remade the documentation API with the help of Moonwave! You can find the new documentation site at ClientCast.
- Fixed an issue with ClientHandler localscript being destroyed when
StarterGui.ResetPlayerGuiOnSpawn = false
. (cc. @XarkDev) - methods such as GetOwner now no longer internally yield, and instantly return the associated values. (cc. @Downrest)
- Added support for rojo and non-studio workflows, categorizing scripts into their appropriate folders.
- Automated releases, such that the code will now automatically pack itself into a .rbxm file and be added into Releases upon a commit.
- Changed to version to follow SemVer semantic versioning.
Hello there!
First, I would like to commend all that you’ve done in regard to the provision of this system to the community, and it is the best material I’ve found on this forum!
I just have an issue pertaining to the hitbox, which is attached to a humanoid in a model of mine. Essentially, I have a range of DmgPoint attachments within a hitbox part, but I’m struggling to prevent self-inflicted damage while also enabling damage to those who collide with the attachments thereof. I was hoping you would be able to solve this problem!
Below is the hitbox I’m referring to
local ClientCast = require(game.ServerStorage.ClientCast)
for i = -2.5, 2.5, 0.1 do -- Creating new attachments called "DmgPoint" within the -2.5 and 2.5 range every 0.1 stud on the Y-axis
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(0, i, 0)
end
for j = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(1, j, 0) -- Note the changes to the attachment positions (X = 1)
end
for k = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(-1, k, 0)
end
for l = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(-2, l, 0)
end
for m = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(2, m, 0)
end
for n = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(0, n, -0.5)
end
for o = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(-1, o, -0.5)
end
for p = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(-2, p, -0.5)
end
for q = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(1, q, -0.5)
end
for r = -2.5, 2.5, 0.1 do
local Attachment = Instance.new("Attachment", game.Workspace.MALWARE.CorruptionAura)
Attachment.Name = "DmgPoint"
Attachment.Position = Vector3.new(2, r, -0.5)
end
local Caster = ClientCast.new(game.Workspace.MALWARE.CorruptionAura, RaycastParams.new()) -- Creates new clientcaster
local Debounce = {}
local MALWARE = script.Parent.Parent
Caster.HumanoidCollided:Connect(function(Result, HitHumanoid)
if Debounce[HitHumanoid] then return end
Debounce[HitHumanoid] = true
local Hit = Result.Instance.Parent
if Hit ~= "MALWARE" then -- Here is the area of focus ... how ensure damage to any humanoid, while also preventing MALWARE's humanoid from being damaged?
HitHumanoid:TakeDamage(20)
wait(0.33)
Debounce[HitHumanoid] = false
end
end)
Caster:Start()
I’ve tried scrolling through this hefty discussion, and I haven’t seen anything pertaining to “3D hitbox cubes”.
Thank you
Hey, ClientCast does not actually offer any debounces by itself to keep maximum customizability in mind. You’d have to check if the hit humanoid originated from the player who used it, and ignore the hit if so.
EDIT: it seems like you’re aware of this, but don’t know how to go about it. You don’t seem to be using this for players (at least, no Owner
is defined), so you can instead do:
local DamagingMob = workspace.MALWARE
Caster.HumanoidCollided:Connect(function(Result, HitHumanoid)
if HitHumanoid:IsDescendantOf(DamagingMob) then
return
end
-- rest of your code
end)
Hey, thanks for making this @PysephDEV. Would I be able to get this to work with native animations?
I have this custom rig with a sword that I’m considering using this for, but I’m cautious because I haven’t been able to get any type of hit detection to work with this rig yet.
i’m pretty sure you can just use .Touched instead of this
.Touched does not provide any information about where exactly the hit was, nor the surface normal at that hit point. It’s also more inaccurate.
Animations update the WorldPosition property of Attachment objects just fine, so it should work in your scenario
Looks like animations only update Attachments if its a part being animated, as opposed to a bone. I had to make a new “Sword” bone and connect the DmgPoint attachments to that with a RigidConstraint, but it’s working! Thanks!
.Touched
is really innacurate and leads to a lot of problems.
only if you aren’t using it right
What do you mean by that, could you explain how to use it “right”?
1.11.0 & 1.12.0
- Added an informative error for when the module is attempted to be required from the client
- Added a yield for
Player.PlayerGui
to prevent issues whenPlayerGui
does not immediately replicate - Updated
Testing.server.lua
to set player Owner - Updated
testing.project.json
to work properly - Removed debug warning which was left out
That’s the API, not really sure how that proves your point?
.Touched
relies of physics-based collisions which makes it unreliable, and why would you use .Touched
when you have better options like WorldRoot:Raycast()
and Region3
or OverlayParams
? They are much more accurate, give you a lot more information about the hit, and WorldRoot:Raycast()
is almost as fast as .Touched
(slightly more expensive, but the pros greatly outweigh the cons).
.Touched can be laggy and its not always accurate, not the best performant-wise either.
I’m having some issues when it comes to making an NPC that swings a weapon in a loop. Now this issue seems to be pretty minor and I’m not sure if it is something I should ignore or not but every time the NPC sword uses ClientCaster it prints this warning: ▶ No replication connection found - Server - ClientCast:344
though it doesn’t seem to affect anything. It just fills up the console and it might be causing an issue I don’t see. I am not setting an owner for the caster btw. Anybody know what to do about this?
Yeah, it’s a warning that was left there by accident which I removed since last update. Simply updating the module to the latest version should fix this!
This was because I originally only expected people to use ClientCast for Client<–>Server communication, but it’s since been supported for just generic server/NPC hitboxes also
Alright thanks. I was confused whether I should’ve been concerned about it or not.