I’m trying to make an effect that with certain weapons, the target’s head comes off. It seems to be working server side, except the head is floating? The client doesn’t even show the head detached. Any idea why? I’ve tried a few things. Here’s the current detach code:
local function headshotDetach(data, target)
local head = target.char:FindFirstChild("Head")
-- For some reason, breaking joints on the head does not work.
-- So we destroy the neck joint which frees the head. We leave
-- the BreakJoints call in place though.
if head ~= nil then
head.CanCollide = true
head:BreakJoints()
local neck = head:FindFirstChild("Neck")
if neck ~= nil then
neck:Destroy()
end
end
end
I’ve isolated it down to CanCollide being true. But I have no idea why that’s causing the problem. It’s not anchored.
Nope. No problems. When CanCollide is false the head just disappears through the floor. But when it’s true, the head remains attached to the body on the client. The server shows the head laying on the ground or floating in the air. Never seen this one before.
Thats a very interesting bug… Did you try reporting this issue not just here but in a bug report aswell? this could be an issue that Roblox needs to fix.
Now that’s interesting. The weapon module is around 10,000 lines of code in multiple scripts. That particular function is called from headshot effects which is in turned called by the headshot detection code in either DamagePlayer or DamageNPC modules.
Here’s a video from the client during solo playtesting:
Here’s a video from the server in local server playtesting.
As I said, I tried different things, but it seems to have something to do with Part.CanCollide on the head itself. I’ve been looking online and it seems that this particular issue hasn’t been experienced before.
@Coolrabbitsaregreen Not yet. I want to make sure it’s an actual bug and not something that I’m doing before I report it.
You know, I have thought about that, but I’m not changing the network ownership which means the server should own them…unless I’m mistaken? These are just normal R15 block rigs from Roblox’s rig builder in the Avatar menu on the ribbon.
EDIT: You know, I think something else is wrong because I expanded the explosive component to just blow the rig apart, and a couple of the rigs reassemble themselves minus the head. Now what’s that about? I’m beginning to think that this is an engine bug, or something is corrupted.
I’m think the server does automaticity own any part form the toolbox. Anyway another option you could try is setting the ownership to nil. If this doesn’t work you could be overloading the client causing the desynchronise between the server and the client as you said you have ten thousand lines of code.
I don’t think overloading the client is an issue since the 10K lines are on the server. I’ve designed the code to execute very fast using task.spawn() and actors with Parallel LUA. So I don’t think that overloading is an issue. But how do you explain the rigs spontaneously reassembling themselves after getting blown apart by an explosion? I know for a fact that my code does not do that.
I tried in a live server. It’s happening there too.
I’ve been able to duplicate it on a clean baseplate. Here’s the file. Let me know if you can duplicate it. I want to make sure that it’s not something screwy going on with my Studio before I file a bug report.
can you try setting rigs humanoid state to physics before detaching or try destroying the humanoid? Also without being sure I think CanCollide should be set to true after you break the joints.
I just tried what you suggested and no difference. The humanoid still reassembles itself within 30 seconds of dying and getting blown apart.
I’m going to have Roblox take a look at this one as it seems to be most definitely an engine bug. I don’t think it’s a coincidence that they have been working on a new humanoid controller which is what this seems to be related to. I’m writing the bug report now. I’ll post a link to it when I’m done.
That did it. The rig stayed in pieces and did not reassemble itself. And I figured out why the head floats. It’s sitting on top of the HumanoidRootPart which has collisions enabled. The part is invisible so you can’t see it sitting there. But that still doesn’t explain why the rig reassembles itself.
Like what sinanxd2 said (destroying the humanoid) the most likely reason the rig reassembled itself could be because the humanoid requires a head and if it identifies a part named head inside the model I believe it would automatically create a weld, reattaching the head.