Player Jittering and sliding around on fast moving train

My posts never actually get any responses for some reason. I hope this one gets through. I want to create a script that keeps the player from sliding and jittering on a fast moving train.

The player will constantly slide around while the train is moving at high speeds.

Ive scowered the devforum for answers, but all either dont give a proper response or use a different method to move the train, though i want it to be physics based. I tried making my own but it doesn’t change anything. The script is on a seperate post.

If anyone could give a proper solution to this, it would be greatly appreciated. Ive seen many games accomplish this but I have no idea how.

2 Likes

Could you provide an example of what you want? This could be helpful.

(I don’t really know if I’ll have the solution but it’ll help other people know what you’re talking about)

1 Like

this was the script i had before. It was trying to update the player’s assemblylinearvelocity every frame to move it with any part it touches.

local RunService = game:GetService("RunService")
lp = game:GetService("Players").LocalPlayer
char = lp.Character
while lp.Character == nil do wait() char = lp.Character end
char = lp.Character

RunService.RenderStepped:Connect(function()
	for _,p in pairs(char:GetDescendants()) do
		if p:IsA("BasePart") or p:IsA("MeshPart") then
			if char:FindFirstChild("HumanoidRootPart") then
				local h
				local function onHit(hit)
					if p.Name ~= "HumanoidRootPart" then
						--p.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
					end
					
					if not char:FindFirstChild(hit.Name, true) then
						char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(hit.AssemblyLinearVelocity.X, char.HumanoidRootPart.AssemblyLinearVelocity.Y ,hit.AssemblyLinearVelocity.Z)
					end
					h:Disconnect()
				end
				h = p.Touched:Connect(onHit)
			end
		end
	end
end)
1 Like

So, what happened? Like was it not updating the AngularVelocity every frame like you desired?

i can’t tell if it does, but it doesn’t appear to be. The result appears to be exactly the same without the script.

Maybe try monitoring the Velocity of your HumanoidRootPart while you’re sliding and see if it changes (and maybe try experimenting).

i got an idea. i will try to put an opposite force on the player instead. i will come back when i try this.

Alright good luck with that! :slight_smile:

1 Like

it didn’t work. And the downside is if i touch an anchored object my game lags and i die.

1 Like

If you could somehow move your player up on the y-axis a little bit, I don’t think it would jitter [as much].

this didn’t work. If the value was too high i would get stuck in the ceiling when i jump and there is no change.

I FOUND THE SOLUTION. the moving script has to be Serversided and inside of the hitbox of the train! for anyone else struggling with this, here is the code.

part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
		local hu = hit.Parent:FindFirstChildWhichIsA("Humanoid")
		local huroot = hit.Parent:FindFirstChild("HumanoidRootPart")
		huroot.AssemblyLinearVelocity = Vector3.new(part.AssemblyLinearVelocity.X, huroot.AssemblyLinearVelocity.Y ,part.AssemblyLinearVelocity.Z)
	end
end)

its way less complex than before.

1 Like

NEW PROBLEM. while the train is on the rails the problem will re appear but if its not there is no issue. is it something with the train’s y position?

NEVERMIND, it was the friction of the rails that messed with it. odd.

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