local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
local LastTrainCFrame
local Function
local Function2
Function = RunService.Heartbeat:Connect(function()
--------------------------------------------------------------- CHECK PLATFORM BELOW
local RootPart = player.Character.LowerTorso
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 == "RaftTop" 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)
This is a script that is supposed to make an object move slowly, but I dont understand the parts where it says to make a LastTrainCFrame and also a player CFrame. I know it has something to do with the camera, but I never used it before. can someone help me with this?
That code is from the jailbreak train thing if I’m correct, if so, that code is only meant to make the player move ontop of cframed parts/anchored parts. Not:
You’ll have to script the object moving part yourself, the script above is only meant to make the player move above the cframed parts as usually cframed parts dont have the player moving along with it.
but I just dont know how to finish the script. sometimes i just want to give up on leaning how to script because its so confusing sometimes. the parts where there are notes says that i have to update the script to make it work in my game because everyone’s game is different. i just dont know what cframe is and i dont know where it shows the cframe. and i also dont know what LastTrainCFrame is. its telling me to make one but i only know a little scripting. then the next part tells me to change it to my player’s cframe, but I dont even know where to find my player’s cframe. in somerandom places it says nil and i know that nil means that there is no information there. Im good at so many things, but this programming is just so hard for me. I just want to be like everyone else and know how to do this. i watch so many videos, but i forget what was being said in the videos because there is so much information. i dont know what to do.
CFrame is a property of a part’s position/rotation in the world. It can be accessed by part.CFrame. Programming is not a thing you learn overnight, try working your way up from the basics to more advanced things. Right now you are being a little ambitious right now.