Custom Characters lag/jitter during when scaled - even simple baseParts

Hey, whenever I scale a custom character (this doesn’t happen with the default R15 character)—even just a simple 6x6x6 BasePart with a Humanoid—the movement lags noticeably as the character gets bigger. The lag only occurs while moving.

Here’s a video showing the issue:

The player has a region that checks nearby parts to eat, and when parts are detected, it scales the character.

Here is the scaling script:

function sizeChanger.scaleProp(player : Player, prop : Model)
	if not prop then
		prop = player.Character
	end
	local score = player:WaitForChild("playerData").score.Value
	local scaleFactor = sizeChanger.getFinalScaleFactor(prop, score)

	prop:ScaleTo(scaleFactor)
	prop:FindFirstChild("Humanoid").WalkSpeed = walkSpeed
end

The player has NetworkOwnership of its characters ofc

try using something like this

local lastScaleForPlayer = {} -- keep track of last scale to avoid redundant scaling

function sizeChanger.scaleProp(player: Player, prop: Model?)
	prop = prop or player.Character
	if not prop then return end

	local score = player:WaitForChild("playerData").score.Value
	local newScale = sizeChanger.getFinalScaleFactor(score)
	local humanoid = prop:FindFirstChildOfClass("Humanoid")

	-- Prevent redundant scaling
	if lastScaleForPlayer[player] == newScale then return end
	lastScaleForPlayer[player] = newScale

	-- Scale the character
	prop:ScaleTo(newScale)

	-- Adjust WalkSpeed proportionally (optional: clamp it if needed)
	local baseSpeed = 16
	local scaledSpeed = baseSpeed * newScale
	humanoid.WalkSpeed = math.clamp(scaledSpeed, 8, 50)

	-- Restore network ownership (just in case Roblox dropped it)
	task.delay(0.1, function()
		for _, part in ipairs(prop:GetDescendants()) do
			if part:IsA("BasePart") then
				part:SetNetworkOwner(player)
			end
		end
	end)
end

Hi! I’m very sure that’s because your script on server. (ScaleTo updates CFrames of objects, and if you call it on server, because of delay between server and client (server always a bit “in past”) you’re being teleported back)

Yeah, that makes sence. but when i scale on the client. its only client sided chagne isnt it? other people wont be able to see the scaled version of my character,right?

also i was wrong, the lag also happens with normal R15 rig.

Hmm, yes, i didn’t thought about it. I think you can use remote events to replicate scaling:

--Server
local Remote:RemoteEvent = game:GetService("ReplicatedStorage").Scale --Some event

Remote.OnServerEvent:Connect(function(Player, Scale)
	Remote:FireAllClients(Player.Character, Scale)
end)
--Client
local Remote:RemoteEvent = game:GetService("ReplicatedStorage").Scale --Some event

Remote.OnClientEvent:Connect(function(Character, Scale)
	if (Character ~= LocalCharacter) then
		Character:ScaleTo(Scale)
	end
end)

These scripts above are just examples, it doesn’t check character existence, doesn’t ensure that event was sent not by exploiters.

2 Likes

Thanks a lot, it works :heart:

scalePropEvent.OnClientEvent:Connect(function(player : Player, prop : Model)
	local score = player.playerData.score.Value
	local scaleFactor = sizeChanger.getFinalScaleFactor(prop, score)
	prop:ScaleTo(scaleFactor)
	if game.Players.LocalPlayer == player then
		local hum = prop:FindFirstChildOfClass("Humanoid")
		if not hum then
			warn("[scalePropEvent] Couldnt find Humanoid")
		end
		hum.WalkSpeed = walkSpeed
		hum.JumpPower = jumpPower
	end
end)

just, is this enought for security?
I have a playerData with players score inside and via that i get the scale factor

Uhh sorry for late reply.
Exploiter can fire remote event from his script, and can insert any data inside, including score.
And if server doesn’t ensure event’s data was sent by your script but not exploiter’s,
he can just type like this: Event:FireServer(99999999) and get this score.
If you need, i’ll write down algorithm for security.

You probably misunderstand me with character check, but i don’t see the point
in this if statement: if game.Players.LocalPlayer == player then

1 Like

Yeah ik, but they cant fake the player. and i just need the player so im alr :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.