#Prismatic Constraint

1 messages · Page 1 of 1 (latest)

distant brook
distant brook
velvet oreBOT
#

studio** You are now Level 1! **studio

distant brook
#

So

#

I cant solve this

indigo rapids
distant brook
#

Right

indigo rapids
# distant brook 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.

distant brook
#

Okay let me see if it will work

#

Doesn't work

indigo rapids
distant brook
#

How to fix that error

#

@indigo rapids

indigo rapids
# distant brook

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.

indigo rapids
distant brook
velvet oreBOT
#

studio** You are now Level 2! **studio

distant brook
#

What I can do now

#

In this cae if it doesnt work

indigo rapids
# distant brook

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

distant brook
#

What about "RootPart"

indigo rapids
distant brook
#

Does this has an fuction or smth

indigo rapids
# distant brook What train mean in this script

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.

distant brook
#

Okay script works but not how it should

indigo rapids
distant brook
#

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

indigo rapids
#

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.

distant brook
#

Well I quit its 3am