How to keep Welds on Player after Death/Respawn

qwdfwe
So I have this script where when the player’s value is a “Soul” then they have these chains welded on their character.

It works but the problem is that if the player resets or dies, then the weld disappears when they respawn. How can I keep the welds on the character? There’s 2 welds, chain1 and chain2. Thanks

local Race = game.Players.LocalPlayer.PlayerValues.Race

Race:GetPropertyChangedSignal("Value"):Connect(function() 
    if Race.Value == "Soul" then 
    	local Chains = game.ReplicatedStorage.Chains.Handle
        local Torso = game.Players.LocalPlayer.Character.UpperTorso
		Chains.CFrame = Torso.CFrame * CFrame.new(0,0,-0.62)

	local weld = Instance.new("Weld")
	weld.Part0 = Torso
	weld.Part1 = Chains
	weld.C0 = Torso.CFrame:Inverse()
	weld.C1 = Chains.CFrame:Inverse()
	weld.Parent = Chains
	
	    local Chains2 = game.ReplicatedStorage.Chains.Handle2
        local Torso = game.Players.LocalPlayer.Character.UpperTorso
		Chains2.CFrame = Torso.CFrame * CFrame.new(0,-0.8,-0.71)

	local weld2 = Instance.new("Weld")
	weld2.Part0 = Torso
	weld2.Part1 = Chains2
	weld2.C0 = Torso.CFrame:Inverse()
	weld2.C1 = Chains2.CFrame:Inverse()
	weld2.Parent = Chains2

    	Chains.Parent = workspace
    	

    	Chains2.Parent = workspace

    end
end)
4 Likes

Try putting the script in StarterCharacterScripts, as it runs everytime the player respawns.

1 Like

That doesn’t seem to work either

1 Like

Just reweld everytime the player respawns. OR disable BreakJointsOnDeath (or some value along the lines of that) in humanoid.

1 Like

Did you have the script run the code outside of the event?

Race:GetPropertyChangedSignal("Value"):Connect(function()

The value won’t change right after the player dies, so you’ll have to run the code outside of the event as well.

if Race.Value == "Soul" then 
    	local Chains = game.ReplicatedStorage.Chains.Handle
        local Torso = game.Players.LocalPlayer.Character.UpperTorso
		Chains.CFrame = Torso.CFrame * CFrame.new(0,0,-0.62)

	local weld = Instance.new("Weld")
	weld.Part0 = Torso
	weld.Part1 = Chains
	weld.C0 = Torso.CFrame:Inverse()
	weld.C1 = Chains.CFrame:Inverse()
	weld.Parent = Chains
	
	    local Chains2 = game.ReplicatedStorage.Chains.Handle2
        local Torso = game.Players.LocalPlayer.Character.UpperTorso
		Chains2.CFrame = Torso.CFrame * CFrame.new(0,-0.8,-0.71)

	local weld2 = Instance.new("Weld")
	weld2.Part0 = Torso
	weld2.Part1 = Chains2
	weld2.C0 = Torso.CFrame:Inverse()
	weld2.C1 = Chains2.CFrame:Inverse()
	weld2.Parent = Chains2

    	Chains.Parent = workspace
    	

    	Chains2.Parent = workspace

    end

--Event after here

And if you’re worried that this’ll take up a lot of lines of code, make this into a function, and call it outside of the event, and in the event itself.

Humanoid.BreakJointsOnDeath = false

1 Like

Yeah it’s still missing even when marking the breakjointsondeath as false. I think I have to do something with the original script.

1 Like

I thought the question was it wouldn’t weld together on the death, and your character wouldn’t weld together, anyways a simple solution is to make a character with it in starter character, or you can make the chain from the player.CharacterAdded event

How do I make a character with it in starter character, every player has their own assets and hats, how can I make a startercharacter that saves their avatar while retaining the weld?

You could clone the character when they are loaded and store it?

That’s just the simple way, not the best, try character added

I tried using character added but it seems to only work with server scripts so I can’t reference specifically if the player matches the stringvalue since thats for local scripts

image

image

You can use get player from character in the server script by doing
workspace.ChildAdded:Connect(function (char) if game.Players:GetPlayerFromCharacter(char) then
–check value, make weld instance.
end end)
If you need a local script, then make a remote event to talk to the server to create the instance using what you did.

I used what you said and checked to see if it works by using a print statement and no results were in the output

image
image

And if I need a local script with a remote event to fire a server script, does this seem correct to be used? Thanks
image

In the above script you said “workplace” not “workspace,” and the below script is correct, just make sure a server script gets it.

Ok thanks, so now the script prints “Yes” after correcting ‘workplace’. But when I add to the script and add a line that checks if player value is human, it does not print “Yes” anymore.
image image
image

All players spawn with the value of “Human” so I don’t see why now the script doesn’t print anything in the output.

I think its because this is a severscript and I can’t reference localplayer.

You have already found your answer, also make sure the value instance is created before that runs, using wait for child.

By putting your weld in a function, you can check if the value is equal to “Soul” when they respawn. Since this is a LocalScript and you want it to load every time the character respawns, you would put this inside of StarterCharacterScripts.

local Race = game.Players.LocalPlayer.PlayerValues.Race
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

local function Weld()
	local Chains = game.ReplicatedStorage.Chains.Handle
	local Torso = Character.UpperTorso
	Chains.CFrame = Torso.CFrame * CFrame.new(0,0,-0.62)
	
	local weld = Instance.new("Weld")
	weld.Part0 = Torso
	weld.Part1 = Chains
	weld.C0 = Torso.CFrame:Inverse()
	weld.C1 = Chains.CFrame:Inverse()
	weld.Parent = Chains
	
	local Chains2 = game.ReplicatedStorage.Chains.Handle2
	local Torso = Character.UpperTorso
	Chains2.CFrame = Torso.CFrame * CFrame.new(0,-0.8,-0.71)
	
	local weld2 = Instance.new("Weld")
	weld2.Part0 = Torso
	weld2.Part1 = Chains2
	weld2.C0 = Torso.CFrame:Inverse()
	weld2.C1 = Chains2.CFrame:Inverse()
	weld2.Parent = Chains2
	
	Chains.Parent = workspace
	Chains2.Parent = workspace
end

if Race.Value == "Soul" then
	Weld()
end

Race:GetPropertyChangedSignal("Value"):Connect(function() 
    if Race.Value == "Soul" then 
    	Weld()
    end
end)
2 Likes

Wow this really fixed my issue, thanks!

1 Like

FYI what @Alphexus said is in just a local script, so other players will not see the weld. Try doing what he did, but using a server script, and getting the character from script.Parent, and getting the player from game.players: GetPlayerFromCharacter (character)