I’ve got this script so far, which works to a point. It lets the player walk around on the moving platform (map1) while it’s being tweened. However, if the player decides to walk about or jump on models that are welded to the moving platform, the player gets randomly teleported elsewhere and I don’t know why? Any help would be appreciated. Full code below
while true do
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
local LastHit
local LastTrainCFrame
local Function
local Function2
local Whitelist = {workspace:WaitForChild('Map1', 20)}
Function = RunService.Heartbeat:Connect(function()
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
if LastHit then
Hit, Position, Normal, Material = workspace:FindPartOnRayWithWhitelist(ray,{LastHit})
if not Hit then
Hit, Position, Normal, Material = workspace:FindPartOnRayWithWhitelist(ray,Whitelist)
end
else
Hit, Position, Normal, Material = workspace:FindPartOnRayWithWhitelist(ray,Whitelist)
end
if Hit then
local Train = Hit
if not LastTrainCFrame then
LastTrainCFrame = Train.CFrame
end
local TrainCF
if Train ~= LastHit and LastHit then
TrainCF = LastHit.CFrame
else
TrainCF = Train.CFrame
end
local Rel = TrainCF * LastTrainCFrame:inverse()
LastTrainCFrame = Train.CFrame
RootPart.CFrame = Rel * RootPart.CFrame
LastHit = Train
if Train ~= LastHit then
LastTrainCFrame = Train.CFrame
end
else
LastTrainCFrame = nil
end
if not Function2 then
Function2 = player.Character.Humanoid.Died:Connect(function()
Function:Disconnect()
Function2:Disconnect()
end)
end
end)
wait(140)
end