I Need Help Keeping The Player Size After They Die

Hello!
Today I need help making a players size keep when they die. What happens is they can collect berries and it will get them bigger, but then if i reset my character the size goes back to normal. Any help? Thanks!

–ServerscriptService
local debounce = false
local parts = game.Workspace.MAP.Level1.Level1Berries:GetChildren()

for i = 1, #parts do

local part = parts[i]

if part.Name == "RedBerries" or 
	part.Name == "BlueBerries" 
then	

	part.Touched:Connect(function(hit)
		
		if debounce == false then
			
			debounce = true				
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)

			if player then
				local Humanoid = hit.Parent:WaitForChild("Humanoid", 3)
				local HS = Humanoid.HeadScale
				local BDS = Humanoid.BodyDepthScale
				local BWS = Humanoid.BodyWidthScale
				local BHS = Humanoid.BodyHeightScale
				game.ReplicatedStorage.GetStrength:FireClient(player, part)

				local leaderstats = player.leaderstats
				local bigness = leaderstats and leaderstats:FindFirstChild("Bigness")

				if bigness then
					bigness.Value = bigness.Value + 1						
					HS.Value += 0.003
					BDS.Value += 0.003
					BWS.Value += 0.003
					BHS.Value += 0.003
					
				end

			end	
			
			local remParent = part.Parent			
			part.Parent	= nil
			
			wait(0.1)		
			debounce = false		
			wait(10) 
			
			part.Parent = remParent			
		end	
	end)
end

end

1 Like

When the player dies then you can store their BodyDepthScale, BodyHeightScale etc to a dictionary and then you can retrieve it and give back the size once the player’s character resets back to normal.

so how would i do that? In the properties of What?

You could do as @Abroxus mentioned, or better yet since all those scales are incremented the same, just make it so when you respawn, it increased the scales values by 0.003 * Bigness.Value

You could set up a PlayerAdded Event, and usign the player parameter it returns, set up a CharacterAdded event, and with the char that the event returns, get the Humanoid, and then add to the scales

1 Like

so i get what you are saying by like restoring it but how would i do that?

An exampel would be this

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		local increment = 0.003 * plr.leaderstats.Bigness.Value
		hum.HeadScale += increment
		--And so on for the other 3
	end)
end)

I recommend combining this code with your leaderstats script, and changing it around to match what you have so far

@apenzijncoolenleuk1 Yours could work as well, but I think it is simpler to just do what I had suggested since @OP uses the same increment for each of the scales, 0.003 multipled by the value in Bigness, if he ever changes the values around, say 0.004 instead of 0.003, all is needed is to change the numbers. Doesn’t require any dictionary work either, just some slight match when a character respawns

2 Likes

In the script you use to change a player’s size, save each player’s size in a dictionary (player instance as a key and the player’s size as a value).

When a player’s character respawn, get the value of that player inside the dictionary and use that to set the size.

Thanks Everyone For All The Help!! :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

2 Likes

Anytime! If you have anymore issues don’t be afraid to make another post!

Also, as a recommendation, I recommend you put 0.003 in the touched event you have that increased your size in a variable and reference that instead, in the scenario you want to increment the scale by adifferent number, so you only have to change the varaible’s content and the thing in the CharacterADded event