I am trying to make a platform that you can jump through from below, but acts as a trampoline when you jump on top of it. I've tried to do it in three ways, but neither of them seems to be perfect:
- Bind the following function to the platform's Touched event:
function onTouch(hit)
if hit.Name == "LeftFoot" or hit.Name == "RightFoot" then
if hit.Parent.HumanoidRootPart.Velocity.Y < -2 then
hit.Parent.HumanoidRootPart.Velocity = Vector3.new(0, 80, 0)
end
end
end
This works in a Studio simulation, but not on a local server, so apparently I can't write to HumanoidRootPart.Velocity directly.
Modify the code to instead add a
BodyVelocityorBodyForceinstance toHumanoidRootPart. This works, but on a local server, it doesn't work quickly enough and the jump only happens after the player has already fallen through the platform.Set the platform's
Velocity.Yto80, and have the script setCanCollideto true or false depending on what way the player touched the platform. This sometimes makes the player jump up and down very quickly, hovering above the platform — I've noticed the same can happen anytime with platforms above ground level with a nonzero Velocity.Y.
Has anyone succeeded in changing the player's Y velocity through a script before? Maybe there's some simple way to do it I've missed?

2 comments
There shouldn't be a problem giving the rootpart velocity. If so try with torso or head.
For some reason none of those work when testing on a local server