Scaling the character makes it "teleport"

I got this problem where the player’s character “teleports” when I change the scale property of the character model.
Does anyone know how to fix this problem? I want the character to scale smoothly and not teleport.

Here is a video showing the problem.

code to change the character’s scale.

script.Parent.Touched:Connect(function(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		local scale = hit.Parent:GetScale()
		hit.Parent:ScaleTo(scale + 0.01)
		script.Parent:Destroy()
	end
end)

Thanks for the help.
/Xsodar

5 Likes

Probably a debounce should fix the issue

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if debounce then return end
	debounce = true
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		local scale = hit.Parent:GetScale()
		hit.Parent:ScaleTo(scale + 0.01)
		script.Parent:Destroy()
		task.wait(1)
		debounce = false
	end
end)

I assume you have the above code inside of a server script. If so, then that is your issue, when you call the ScaleTo function it also updates the parts CFrames. Since you call it on the server the parts CFrames will always be lagging behind because of latency and it will update the parts to those lagging CFrames which results in the teleporting you are seeing.

In order to fix this you would have to call the ScaleTo function on the client.

Sorry for the very late response but you’re right that’s the problem.
The problem now is that if I call the function on the client it only shows on the client and not the server. Do you know how to make it smooth but also scale the character on the server?
I have tried using remote events and it works kind of, it still “lags” but makes it a bit better. I guess I have to override the ScaleTo function on the server but how?

Thanks for the answer though : )

No worries. I guess there is really no conventional way to make the ScaleTo function appear smooth from the server when the character is moving. So I figured for your case, instead of using the ScaleTo function you could just manually scale the character using the values under the humanoid. I wrote up a function that would achieve that, all you need to do is call it from the touched event on the server and it should appear smooth.

local function ScaleCharacter(Character, ScaleFactor)
	local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
	if Humanoid then
		for _, child in (Humanoid:GetChildren()) do
			if child:IsA("NumberValue") then
				if child.Name == ("HeadScale") or child.Name == ("BodyDepthScale") or child.Name == ("BodyWidthScale") or child.Name == ("BodyHeightScale") then
					child.Value *= ScaleFactor
				end
			end
		end
	end
end

I’m having this same issue and this is not a solution for skinned meshes unfortunately. The main reason being is that ScaleTo() scales animations for the new mesh size.

The best I have so far is the scale the local player, then fire a server event that then fires events on all the other clients to scale that specific player as well (skipping the already scaled local player of course).

The issue with this now is that the player on other clients freezes for a second, then teleports to their new position. It’s better than the player teleporting every time they pick up something, but it would be nice if there was no teleporting at all.

My bandaid at the moment has been to just only update the other clients every once in a while instead of all the time.