Player teleporting when falling to a part / jumping onto a part?


When I was testing my game, I tried doing an obby and whenever I would jump onto like a cloud or fall onto a cloud, it would just teleport the player somewhere else but not teleport them on the cloud. I believe this is the script that’s causing it?

local RunService = game:GetService("RunService")

local Character = script.Parent
local RootPart = Character:WaitForChild("Head")
local LastTrainCFrame, Connection

local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
local stickyParts = {
	CloudPlatform = true,
	--AnotherName = true,
}

RunService.Heartbeat:Connect(function()
	local result = workspace:Raycast(RootPart.Position, -Vector3.yAxis*50, Params)
	local target = result and result.Instance

	if target and stickyParts[target.Name] then
		local TrainCF = target.CFrame 
		if LastTrainCFrame == nil then -- If no LastTrainCFrame exists, make one!
			LastTrainCFrame = TrainCF  -- This is updated later.
		end
		local Rel = TrainCF * LastTrainCFrame:Inverse()

		LastTrainCFrame = TrainCF  -- Updated here.
		RootPart.CFrame = Rel * RootPart.CFrame -- Set the player's CFrame
	else
		LastTrainCFrame = nil -- Clear the value when the player gets off.
	end
end)
1 Like

Can you show a video of it happening?

Let me go record the video real quick.

1 Like

robloxapp-20250313-1747140.wmv (4.3 MB)
I don’t know if the video quality may be good but I don’t have any video recording software so I just used roblox’s video recording.

Is it supposed to move or stick them in any way?
I’m guessing this is a free model script/cloud that you are using.

If you just need them as platforms then make the script inactive and test it. If it works correctly for walking & jumping then just delete the script.

1 Like

Well, it is a free model but I added a platform for the player to stand on also the script didn’t come with it. Previously, I wanted the player’s character model to move along with the move cloud at the start but it didn’t work and this script was apparently the solution to it but now it has caused another problem. (The local script is located in startercharacterscripts)

Why do you want them to teleport to the cloud? I wouldn’t really recommend doing that, for gameplay purposes.

No no, I don’t want them to teleport to the cloud.

I want them to move with the moving cloud (at the start) that was moving but I didn’t know it would teleport them randomly when they fell to a cloud or jumped up to a cloud.

Alright, let me get you a script to do so.

The script kind of solved the problem but I discovered that when a player’s falls to a cloud or jumps to the cloud near the center, it would just randomly teleport them idk why it does that?

Okay, i can’t access studio right now but;
I’ve found a post that might explain to you how to go with it.
Check it out here:

If you do not know how to tween, here’s how to:

local TweenService = game:GetService("TweenService")

local goal = {}
goal.Position = Vector3.new(-121.25, 4, -44.25)

local Tweeninfo1 = TweenInfo.new(
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true,
	1
)

local tween = TweenService:Create(script.Parent, Tweeninfo1, goal)

tween:Play()

I mean I understand the explaination from that post but where is the solution to fix it? Was there supposed to be a script there?

Since i can’t really access studio right now, you’ll probably have to make it yourself, but that prob won’t be too complicated, it’s quite easy to find solutions by looking things up and digging for a bit.

Here’s another post i found with a script that you’ll be able to adapt to your cloud if you know a minimum of scripting.

I will go try that script and see if it works later (I have to eat dinner).

1 Like

Hey uh, that script has A LOT of deprecated stuff. I can’t really find the current ones.

Alright, I tried the deprecated script and also attempted to modify it using the new versions of the deprecated functions and both failed.

I’m guessing you were CFrame moving the cloud? That won’t work to move players unless you update the players CFrame every frame.
You could use a Constraint to move the cloud. If it’s a straight line just use a PrismaticConstraint. Since constraints are physics based players are affected by them.

No no. The script does move the player on the moving cloud. It’s the middle part of the obby, where when the players fall to another cloud or jump onto that cloud, they player will teleport off (It’s not moving just anchored there)

Ah, k.
But if you were using PrismaticConstraints to move the clouds it wouldn’t cause that.

It sounds like when the player is already touching a cloud the CFrame is being updated properly, but when they drop off their CFrame is being miscalculated.
The script should be reading the player’s CFrame as soon as it lands on (touches) a cloud, then start controlling their movement from that location.