Have players stay on the platform while resizing?

I have a platform in my gamemode with model “models/hunter/plates/plate5x5.mdl” and I currently have this:


platform:SetModelScale(2, 5)

and after 5s I call:


platform:SetModelScale(1, 5)

in a loop to make the platform grow and shrink every 5 seconds.

This works, HOWEVER, if a player is standing on it while it grows, they get stuck inside of it and they have to wait for it to shrink again to get unstuck. How can I make it so the player stays on the platform as it grows and shrinks without any jitter or lag?

You’ll have to manually move them up due to how the collision model is scaled. You can do this by checking if any player is standing on the platform during scaling (

Entity:GetGroundEntity) and

util.TraceHull to find where the platform is.

I dont quite understand how TraceHull works :confused: how would I go about using it in this situation?

Each tick the player is on the prop, trace from a unit above the player’s position down to the prop and set their position there. It would actually be better to use

util.TraceEntity instead.

So I did this:



local upwardPos = Vector(ply:GetPos().x,ply:GetPos().y,ply:GetPos().z+1)
local trace = {start = upwardPos, endpos = upwardPos, filter = ply}
local tr = util.TraceEntity(trace, gEnt)
ply:SetPos(Vector(ply:GetPos().x,ply:GetPos().y,tr.HitPos.z))


(gEnt == ply:GetGroundEntity())

and the player jitters like mad whenever they’re on the platform. Am I doing this right?

[editline]23rd October 2017[/editline]

EDIT: It works just flawlessly without the +1 on the z, thanks for the help!