Character script not working after reset

Hello. I am trying to make a game in my group where people have long legs but the rest of their body is normal. When I spawn in the script works and it looks like I want it to, but when I reset or die everything in the first script doesn’t work for some reason and my whole body is long instead of just the legs. I have tried to create a second debounce with died, had it check if a body part was the correct size, and more, but nothing worked. I was hoping if someone could help me find out how to make it work after you die or reset.

This is the first script that changes the location and size of everything but the legs so everything is the right size and position. It works when I spawn in, but not when I reset or die.

local button = script.Parent
local isTouched = false
local died = true
button.Touched:Connect(function(hit)
	humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid')
	if humanoid then
		if isTouched ==  false or died ==  false then
				local body = hit.Parent
				humanoid.WalkSpeed = humanoid.WalkSpeed*2
				humanoid.JumpHeight = humanoid.JumpHeight*2
				body.LowerTorso.Size = body.LowerTorso.OriginalSize.Value
				body.LeftFoot.Size = body.LeftFoot.OriginalSize.Value
				body.LeftHand.Size = body.LeftHand.OriginalSize.Value
				body.LeftLowerArm.Size = body.LeftLowerArm.OriginalSize.Value
				body.LeftUpperArm.Size = body.LeftUpperArm.OriginalSize.Value
				body.RightFoot.Size = body.RightFoot.OriginalSize.Value
				body.RightHand.Size = body.RightHand.OriginalSize.Value
				body.RightLowerArm.Size = body.RightLowerArm.OriginalSize.Value
				body.RightUpperArm.Size = body.RightUpperArm.OriginalSize.Value
				body.UpperTorso.Size = body.UpperTorso.OriginalSize.Value
				body.Head.Size = body.Head.OriginalSize.Value
				body.HumanoidRootPart.Size = body.HumanoidRootPart.OriginalSize.Value
				body.UpperTorso.Position = body.UpperTorso.Position + Vector3.new(0, -4.5, 0)
				body.Head.Position = body.Head.Position + Vector3.new(0, -8, .5)
				body.LeftUpperArm.Position = body.LeftUpperArm.Position + Vector3.new(-.1, -.7, 0)
				body.LeftLowerArm.Position = body.LeftLowerArm.Position + Vector3.new(0, 1.8, -.2)
				body.LeftHand.Position = body.LeftHand.Position + Vector3.new(0, 4.5, -.2)
				body.RightUpperArm.Position = body.RightUpperArm.Position + Vector3.new(-.1, -5.2, -.6)
				body.RightLowerArm.Position = body.RightLowerArm.Position + Vector3.new(0, -2.7, .7)
				body.RightHand.Position = body.RightHand.Position + Vector3.new(0, 0, .7)
				body.HumanoidRootPart.Position = body.HumanoidRootPart.Position + Vector3.new(0, -4.5, 0)
				body.Animate.ScaleDampeningPercent.Value = 2.5
				humanoid.HipHeight = 10
				isTouched = true
				died = true
		end
	end
end)

if humanoid then
	if humanoid.Health == 0 then
		died = false
	end
end 

This is also a script that is in StarterCharacterScripts in StarterPlayer. This script works fine even if I die and elongates the whole body.

local humanoid = script.Parent.Humanoid
local person = script.Parent

humanoid.BodyHeightScale.Value = humanoid.BodyHeightScale.Value*6

There is no error code that pops up in the output or in the script even though it does not work. Here are some pictures to help you with what the right character should look like.

What I want it to look like:
Correct Character - Roblox Studio (gyazo.com)

What it looks like after the reset:
Wrong Character - Roblox Studio (gyazo.com)

Alright, there are a couple of things wrong with this script,

  1. This is a serverscript, it shares the same died variable throughout everyone
  2. You arent correctly resetting the died variable

These things could be easily fixed by removing the died variable and instead testing if the humanoid’s health is above zero

I removed the died variable but I am not sure how to check if the humanoid’s health is above zero. I am not sure how to test the humanoid’s health though and make it connected.

The reason why your script does not work after reset is because the code you wrote to check if humanoid has died does not fire. Like mentioned, you’re running this on a server script, the died variable will be there for the entire script, not locally.

If you’re trying to stretch someone’s body once, then you can use this alternative.

  • First remove the died & isTouched variables.
  • Then, we need to use a reference point for your script to know if the player has already touched the part. In this case, I used Humanoid’s HipHeight
  • When you spawn, your Humanoid’s HipHeight is set to 12, but when you touched the part it’s set to 10.

So essentially, instead of checking the bools, you can check if Humanoid.HipHeight > 10
Hope it helps.

local button = script.Parent

button.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid')
	if humanoid then
		if humanoid.HipHeight > 10 then
			print("doing")
			local body = hit.Parent
			humanoid.WalkSpeed = humanoid.WalkSpeed*2
			humanoid.JumpHeight = humanoid.JumpHeight*2
			body.LowerTorso.Size = body.LowerTorso.OriginalSize.Value
			body.LeftFoot.Size = body.LeftFoot.OriginalSize.Value
			body.LeftHand.Size = body.LeftHand.OriginalSize.Value
			body.LeftLowerArm.Size = body.LeftLowerArm.OriginalSize.Value
			body.LeftUpperArm.Size = body.LeftUpperArm.OriginalSize.Value
			body.RightFoot.Size = body.RightFoot.OriginalSize.Value
			body.RightHand.Size = body.RightHand.OriginalSize.Value
			body.RightLowerArm.Size = body.RightLowerArm.OriginalSize.Value
			body.RightUpperArm.Size = body.RightUpperArm.OriginalSize.Value
			body.UpperTorso.Size = body.UpperTorso.OriginalSize.Value
			body.Head.Size = body.Head.OriginalSize.Value
			body.HumanoidRootPart.Size = body.HumanoidRootPart.OriginalSize.Value
			body.UpperTorso.Position = body.UpperTorso.Position + Vector3.new(0, -4.5, 0)
			body.Head.Position = body.Head.Position + Vector3.new(0, -8, .5)
			body.LeftUpperArm.Position = body.LeftUpperArm.Position + Vector3.new(-.1, -.7, 0)
			body.LeftLowerArm.Position = body.LeftLowerArm.Position + Vector3.new(0, 1.8, -.2)
			body.LeftHand.Position = body.LeftHand.Position + Vector3.new(0, 4.5, -.2)
			body.RightUpperArm.Position = body.RightUpperArm.Position + Vector3.new(-.1, -5.2, -.6)
			body.RightLowerArm.Position = body.RightLowerArm.Position + Vector3.new(0, -2.7, .7)
			body.RightHand.Position = body.RightHand.Position + Vector3.new(0, 0, .7)
			body.HumanoidRootPart.Position = body.HumanoidRootPart.Position + Vector3.new(0, -4.5, 0)
			body.Animate.ScaleDampeningPercent.Value = 2.5
			humanoid.HipHeight = 10
		end
	end
end)

It fixed the issue of it not working after the reset, but for some reason it seems like the checking if the hipheight is over 10 does not work, because the walkspeed and the jumpheight keep being multiplied by 2 and “doing” gets repeated many times.

It’s likely because I do not have the entire script, my character did not look nearly close to what you had in the screenshots. I used the HipHeight reference point because of the StarterPlayer script you provided, which sets it to 12 when you spawn and 10 to when you touch the part.

The point is, do not use variables in this case, use a reference point instead that works for your game.

Ok thanks! I will keep this in mind, and ya something happened where mine no longer looks like that so I am fixing that also.