#Why my Train it Shaking

1 messages · Page 1 of 1 (latest)

sand escarp
#

Somebody said "Humanoids was not really designed for it.
Instead you may try applying velocity"

#

I dont get what is mean

#

Moving Train: [Script]

local Support = workspace.Support
local RunService = game:GetService("RunService")
--wait(2)

local speed = 70 -- Studs per second (5 units / 0.1 seconds = 50 studs/sec)

RunService.Heartbeat:Connect(function(deltaTime)
    local distanceToMove = speed * deltaTime

    Train:PivotTo(Train:GetPivot() * CFrame.new(0, 0, distanceToMove))
    Support:PivotTo(Support:GetPivot() * CFrame.new(0, 0, distanceToMove))
end)```
#

PlatfromStick: [LocalScript]

local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')

local LastTrainCFrame

local Function
local Function2


Function = RunService.Heartbeat:Connect(function()

    --------------------------------------------------------------- CHECK PLATFORM BELOW
    if not player.Character:FindFirstChild("HumanoidRootPart") then return end
    
    local RootPart = player.Character.HumanoidRootPart

    local Ignore = player.Character

    local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))

    local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)
    

    if Hit and Hit.Name == "NotFall" then -- Change "RaftTop" to whatever the moving part's name is

        --------------------------------------------------------------- MOVE PLAYER TO NEW POSITON FROM OLD POSITION

        local Train = Hit
        if LastTrainCFrame == nil then -- If no LastTrainCFrame exists, make one!
            LastTrainCFrame = Train.CFrame -- This is updated later.
        end
        local TrainCF = Train.CFrame 

        local Rel = TrainCF * LastTrainCFrame:inverse()

        LastTrainCFrame = Train.CFrame -- Updated here.

        RootPart.CFrame = Rel * RootPart.CFrame -- Set the player's CFrame
        --print("set")

    else
        LastTrainCFrame = nil -- Clear the value when the player gets off.

    end

    Function2 = player.Character.Humanoid.Died:Connect(function()
        Function:Disconnect() -- Stop memory leaks
        Function2:Disconnect() -- Stop memory leaks
    end)

end)```
candid nebula
#

lol what a disaster

#

if you want the player to move with the train, then give the train some assemblylinearvelocity instead of just tweening everything.

west cobalt