breaking the connection as the player dies might be a bit risky as it would depend on which occurs faster, the weldconstraint breaking or the humanoid dying.
local module = {}
module.Grab = function(part,grabtime,instantdmg)
local contact = false
local tconnect = part.Touched:Connect(function(hit)
if hit and hit.Parent and part and part.Parent and hit.Parent:FindFirstChild("Humanoid") and part.Parent:FindFirstChild("Humanoid") and
hit.Parent.Humanoid.Health > 0 and part.Parent.Humanoid.Health > 0 and not contact and hit.Parent:IsA("Model") and part.Parent:IsA("Model") then
contact = true
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - instantdmg
local massmod = require(game.ReplicatedStorage.Mods.Util.CompareModelMass)
local biggestmodel = massmod.Compare(hit.Parent,part.Parent)
if hit.Parent == biggestmodel and part.Parent:FindFirstChild("Humanoid") then
part.Parent.Humanoid.PlatformStand = true
elseif part.Parent == biggestmodel and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.PlatformStand = true
end
local weld = Instance.new("WeldConstraint")
weld.Parent = part
weld.Part0 = part
weld.Part1 = hit
wait(grabtime)
if weld then
weld:Destroy()
end
if hit.Parent == biggestmodel and part.Parent:FindFirstChild("Humanoid") then
part.Parent.Humanoid.PlatformStand = false
elseif part.Parent == biggestmodel and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.PlatformStand = false
end
end
end)
wait(1)
if contact == false then
if tconnect then
tconnect:Disconnect()
end
end
end
return module
this is the module for the ability.
during the event of both humanoids dying, the last damage to occur to one humanoid is the instantdmg in this module.
(sorry about the code format I forgot to add the ``` before pasting)
so is humanoid death.
say for example I setup a humanoid.died event.
when the humanoid dies, this will do something.
I could detach the weld using this method, but because the humanoid died first to fire that event, the weld will still be attached, leading to both humanoids attached to die.
I could check for the hp and see if it is 0, but again, when the humanoid hp is at 0, will the humanoid dying be faster than the if statement checking its hp?
this is why I was asking for something that could prevent this altogether. maybe a way to disable joint breaking completely.
What is the hierarchy of your rigs? When I spawn in two animation rigs, hook them together with a WeldConstraint, then kill one, it doesn’t impact the other. Perhaps there are other factors at play?
after doing some checking I noticed some interesting behavior.
the rigs are for custom characters and a player can load one up as their character.
when I connected two rigs that are not a player, they wont die when connected by weldconstraint.
however, if I connect the player with any other rig, both humanoids die.
initially when I looked at the rigs, the custom ones had to be connected with weldconstraints because normal welds wouldnt form.( I think this might be because a humanoid was inside the rig while I was modeling it). but after testing with a normal default rig from the rig spawning plugin, the same results happened regardless.
it has to do with the player somehow and Idk why.
heres the custom character change script:
script
local respawntime = 3
game.Players.CharacterAutoLoads = false
local newcharmod = require(game.ReplicatedStorage.Mods.Util.NewCharacter)
game.Players.PlayerAdded:Connect(function(plr)
--if player dies reload custom char----------------------------
plr.CharacterAdded:Connect(function(char)
if char and char:FindFirstChild("Humanoid") then
char.Humanoid.Died:Connect(function()
local folder = game.ServerScriptService.PlrData:FindFirstChild(char.Name)
if folder then
folder.BeginCreatureRun.Value = nil
folder.Hunger.Value = 100
end
wait(respawntime)
newcharmod.CreateNew(plr,game.ServerStorage.BaseRig,Vector3.new(0,5,0))
end)
end
end)
---------------------------------------------------------------
--setting the model without humanoid death--
newcharmod.CreateNew(plr,game.ServerStorage.BaseRig,Vector3.new(0,5,0))
-----------------------------------------
end)
character spawning module
local module = {}
module.CreateNew = function(plr,newmodel,newpos)
if plr and newmodel then
plr:LoadCharacter()
local bod = newmodel:Clone()
wait()
bod.Parent = game.Workspace
bod.Name = plr.Name
wait()
repeat
wait()
until
bod.Parent == game.Workspace
plr.Character = bod
bod:SetPrimaryPartCFrame(CFrame.new(newpos))
wait()
plr.PlayerGui.UpdateCam:FireClient(plr,bod.Humanoid)
end
end
return module
Can either of the players move while linked? If not, anchoring them should work. I’ve been messing around since you brought up that it’s only a player-related issue, and even using a part as proxy doesn’t help.
Alternatively, you might be able to accomplish the task with a precisely-oriented PrismaticConstraint with length set to the distance between the two parts.