#Prismatic Constraint
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
So you're saying that you want to keep your momentum when you jump, so you land on the same spot on the platform, right?
Right
Well then I wouldn't say anything is wrong with your code then, because you don't attempt to do that. However, this code acquired from dev forums appears to sort out that issue by updating the character's cframe each heartbeat. You can look at how it works and try and implement it in your code.
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)
Credit: Kord_K, https://devforum.roblox.com/t/jailbreak-train-platform-system/236339/34
Dev forums are a powerful tool for solving common issues. Learning how to use them will be very beneficial in learning how to code.
How so? Are you getting any errors?
How to fix that error
@indigo rapids
Okay it looks like you probably copy pasted the code at the end of your previous script. You'll have to put the code in a local script (in starter player), and change variable names etc. so that it works with your game.
Alr
Still doesnt work
Show me your local script
** You are now Level 2! **
You still need to personalize the code so that it works for your specific case. As the comment on ln 23 suggests, Change "RaftTop" to whatever the moving part's name is
Oh okay
What about "RootPart"
That one should be okay, as that's just the name of a variable defined to be the character's lower torso.
What train mean in this script
Does this has an fuction or smth
The code was made for someone doing the same thing as you, but with a train. I would recommend changing them to something more apt, like "Platform" or "MovingPlatform", (while making sure to keep the names consistent) but it should work either way.
Okay script works but not how it should
show me
Script literally directly teleport me to place where I was
And I cant move by it
I dont have autonomy to it
During it moves I stay in place because it teleport me in directly place where I have been before that platform have moved
Now how to solve this
@indigo rapids
Any tips
Hmm weird. A video of it working properly was provided in the dev forums, so I assumed it worked okay without testing it. I'm not sure why it's not working in your case, maybe someone else with more experience here can help.
Well I quit its 3am