Scaling Character sometimes does not replicate to client at runtime

Whenever I scale my character at runtime, sometimes the scaling doesnt not replicate to client thus my character looks small on client and large on server

this has about a 15-20% chance of happening at runtime

Client

Server

this happens both in game and in studio and only happens at runtime

Players.PlayerAdded:Connect(function(Player)
	
	local data = DataModule:ReturnData(Player)
	
	local character = Player.Character or Player.CharacterAdded:Wait()
	data[2].LoadedStage = StageModule:GetStage(Player)
	
	local function characterAdded(char)
		
		character = char
		StageModule:LoadStage(Player, char)
		GrowModule:UpdateTempScales(data, character) -- I update a table with scales
		GrowModule:ApplySize(data, character) -- I update the characters humanoid scales based on the table of scales
		
	end	
	
	characterAdded(character)
	Player.CharacterAdded:Connect(characterAdded)
	
end)
function GrowModule:UpdateTempScales(Data, Character)
	
	
	if Data and Character then
		
		local loadedStage = Data[2].LoadedStage
		local humDesc = loadedStage.HumDesc
		local humanoid = Character.Humanoid
		
		Data[2].ScaleObjects = {humanoid.BodyDepthScale, humanoid.HeadScale, humanoid.BodyHeightScale, humanoid.BodyWidthScale}
		Data[2].DefaultScales = {humDesc.DepthScale, humDesc.HeadScale, humDesc.HeightScale, humDesc.WidthScale}
		
	end
	
end

function GrowModule:ApplySize(Data, Character)
	
	if Data and Character then
		local scaleObjects = Data[2].ScaleObjects
		local defaultScales = Data[2].DefaultScales
		local loadedStage = Data[2].LoadedStage
		
		local size = (Data[1].Size * loadedStage.ScalePerSize)
		for i = 1, #scaleObjects do
			print("Scaled")
			scaleObjects[i].Value = defaultScales[i] + (defaultScales[i] * size)
		end
		
	end
	
end

is this a bug, or is this an issue on my part?

I looked around online but the only results are related to animations

Edit:
there are no errors and if I reset (which scales when I spawn) it works normally

Edit2:
after testing a lot it’s not strictly limited to runtime and happens when character loads, I’m guessing it’s because I’m adding the character and then scaling instantly going to investigate some more

1 Like

well I added a wait(1) after the character spawns and it works, but annoying having to have a delay

1 Like

You should just check if the size values exist and if not then WaitForChild for them, just to be safe.

wait() is bad practice for loading since the time to load could vary, and using wait() can either fail if the values haven’t loaded yet, or add unnecessary time to the execution otherwise.

1 Like

That’s not the issue, the values are being updated but it’s just not replicating to client sometimes

Edit: I also tested this just in case and it makes no difference the issue is still happening

1 Like

Attempt using Player.CharacterAdded:Wait() for a more accurate wait

2 Likes

I’m using

 Player.CharacterAdded:Connect(characterAdded)

wouldn’t adding that be redundant as that event was already fired?

Players.PlayerAdded:Connect(function(Player)
	
	local data = DataModule:ReturnData(Player)
	local character

	data[2].LoadedStage = StageModule:GetStage(Player)
	
	local function characterAdded(char)
		
		character = char
		StageModule:LoadStage(Player, char)
		GrowModule:UpdateTempScales(data, character) -- I update a table with scales
		wait(1)
		GrowModule:ApplySize(data, character) -- I update the characters humanoid scales based on the table of scales
		
		char.Humanoid.Died:Connect(function()
			char:Destroy()
			Player:LoadCharacter()
		end)
		
	end	
	
	Player.CharacterAdded:Connect(characterAdded)
	
	
	Player:LoadCharacter()
	
end)

also that was already used previously

if I change any scale value locally or on server when the issue happens even by a tiny amount all of the scales will be replicated

It could just be the way the roblox engine works then, where things won’t replicate unless they are actually moving I’m guessing. For example, roblox doesn’t replicate anchored parts. I’m sure there’s some condition that is caused roblox to decide that the scale doesn’t need to be replicated.

In that case then waiting might be the best option

Could it possibly be that the character has been added but the values themselves haven’t loaded yet? (The size values in the humanoid)

That’s what I was thinking but he said the values are being updated. If they didn’t exist yet then attempting to change them would give an attempt to index a nil value error

Yeah I think waiting will be fine in this case if there are no other solutions because I don’t believe the issue is with loading because it also happens sometimes when I respawn

@PirateOnThePlank the values are loaded because I change the value of them, when the issue is happening if I go to the body scale values on client or server they are set to the correct numbers but rather the size itself is not replicating but the values are

server vs client


That’s odd behaviour, but I guess it is what it is. As one last try, could you try
using Player.CharacterAppearanceLoaded before you ApplySize()?

I’ve already tried that out, and again just now to be sure and it still occurs

Been having similar issues in Bloxburg, but never been able to properly reproduce.

An update a while back introduced a lot of strange replication issues with HumanoidDescriptions, so guessing it’s related to: Avatar looks messed up on the client and fine on the server when scaled

4 Likes

Found a solution/work around

Instead of instantly scaling whenever the character spawns (this is the only time the issue occurs as far as I know)

I’m now adjusting the scale values of a cloned Humanoid Description and using

Player:LoadCharacterWithHumanoidDescription(GrowModule:GetScaledDescription(data))
function GrowModule:GetScaledDescription(Data)
	
	local scaleNames = {"DepthScale", "HeadScale", "HeightScale", "WidthScale"}
	local defaultScales = Data[2].DefaultScales
	local loadedStage = Data[2].LoadedStage
		
	local size = (Data[1].Size * loadedStage.ScalePerSize)
	local scaledStage = loadedStage.HumDesc:Clone()
		
	for i = 1, #scaleNames do
		scaledStage[scaleNames[i]] = defaultScales[i] + (defaultScales[i] * size)
	end
	
	return scaledStage
	
end

so far this works fine, and is actually less code

3 Likes