Player jump on moving unanchored platform, Landed State delay

  1. What do I want to achieve? Player can jump on a moving platform that isnt anchored while still being able to stay on it.

  2. What is the issue? After jumping, the state “Landed” comes too late which make the character keep applying the platform velocity, and I don’t want that, I want it to stop as soon as it landed.

External Media
  1. What solutions have I tried so far? I tried to check those jailbreak things, but they work on anchored platform, and I can’t find a solution for my issue, but I really need it since I’m trying to make a train in which players could stay, jump, without having to worry about anything.

The train is not anchored, because setting the whole train to anchored while moving the model drop the FPS like crazy. And I didn’t even talked about how buggy it look like.

Here’s a video where I tried with anchored thing from Jailbreak train platform system? - #35 by Kord_K

External Media
local Character = game.Players.LocalPlayer.Character
local SavedVelo = Vector3.zero

local asJumped = false

Character:FindFirstChildOfClass("Humanoid").StateChanged:Connect(function(o,n)
	if n == Enum.HumanoidStateType.Landed then
		if asJumped then
			asJumped = false
		end
	end
end)
game:GetService("UserInputService").JumpRequest:Connect(function()
	asJumped = true
end)

game:GetService("RunService").RenderStepped:Connect(function()
	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Exclude
	Params.FilterDescendantsInstances = {Character}
	
	local RayOrigin = Character.PrimaryPart.Position
	local RayDirection = Vector3.new(0, -50, 0)
	local Raycast = workspace:Raycast(RayOrigin, RayDirection, Params)
	
	if Raycast then
		local Inst:Instance = Raycast.Instance
		if Inst:IsA("BasePart") then
			local LinearVelocity = Inst.AssemblyLinearVelocity
			
			if asJumped then
				local ALV = Character.PrimaryPart.AssemblyLinearVelocity
				Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(LinearVelocity.X+SavedVelo.X, ALV.Y, LinearVelocity.Z+SavedVelo.Z)
			else
				SavedVelo = Character.PrimaryPart.AssemblyLinearVelocity
			end
		end
	end
end)

Thanks in advance!

1 Like