I've been making a forcefield that protects its user from almost anything. It usually does this by teleporting any object it interacts with to its outer edge. Of course it's not foolproof and if something with enough momentum hits it they can briefly interact with the NPC or Player inside of the forcefield, allowing damage to take place.

Then whilst searching roblox gears I came across this bit of code which fixed the problem of taking regular damage:

local IgnoreHealthChange = false
local CurrentHealth = Human.Health
		Human.Changed:Connect(function(Property) -- Based on Azure Periastron
			local NewHealth = Human.Health
			if not IgnoreHealthChange and NewHealth ~= Human.MaxHealth then
				if NewHealth < CurrentHealth then
					local DamageDealt = (CurrentHealth - NewHealth)
					IgnoreHealthChange = true
					Human.Health = Human.Health + (DamageDealt * .25)
					--print((HasPeri("Azure") and "Has Azure") or "Does not have Azure")
					IgnoreHealthChange = false
				end
			end
			CurrentHealth = NewHealth
			
		end)

This has worked very well in keeping the NPC/Player alive when they're hit with something that just deals damage.

Is it possible to do something similar for BreakJoints in order to keep the NPC/Player alive even if it interacts with BreakJoints causing attacks? - BreakJoints has been a thorn in my side for a while.

EDIT: I've been trying to make something that will do the job, but so far, nothing has worked. The best I could come up with is this:

Character = script.Parent

local neck = Character.Head:FindFirstChild("Neck")
local neckclone = Character.Head:FindFirstChild("Neck")
neckclone.Parent = script

local Services = {
	RunService = (game:FindService("RunService") or game:GetService("RunService"))
}

if not neck then
	Services.RunService.Heartbeat:Connect(function(m)
		local NewNeck = script:FindFirstChild("Neck")
		NewNeck.Parent = Character.Head
		Character.Anchored = true
		for _,i in pairs (m:GetDescendants()) do
			if i:IsA("BasePart") then
				i:MakeJoints()
				i.Anchored = false
			end
		end
	end)
end

This script will fix the neck joint if you delete it without the player dying. I thought the removal of the neck joint is the exact reason BreakJoints ends up killing players but this did not make the player survive either. I have checked and no other joints appear to be necessary to survival on R15 bodies; you can delete all the Motor6D's in a player except for Neck Joint and they'll live. I'm still stumped for a solution.

7 comments

0

I guess you could use something like :MakeJoints() but it probably won't work for humanoids. Try loading the character.

0

Does MakeJoints actually make all the joints that BreakJoints will break? I had tried something similar once but it didn't really work. As for loading the character that will not do because constantly loading things causes issues and isn't exactly fun either.

0

It seems what ends up killing characters is the removal of the Neck Joint, but it's a little weird...

0

By removing the Neck Joint you kill the player, however, if you duplicate the Neck Joint then move the original Neck Joint outside of the player model then you can delete it without killing the player. However if you do the same but instead of deleting it your player hits something with Break Joints this doesn't work.

0

Either way, no matter what I do this seems impossible. Is it actually impossible to reverse BreakJoints and survive?

0

No, it won't reverse.

0

Aww really? That's ashame.