Moving part leaves players back

Hello, fellow developers!

Today, I made a moving part and it worked pretty well. But it had one issue, It left behind the player as it moved. The only solution I could think of was adding a seat above it, but that just looks weird and usually takes time to jump off, instead I wanted it to move smoothly with the player. Don’t know what’s wrong, here’s the script:

function move(x,y,z)
for i=1,20 do
script.Parent.Position = script.Parent.Position + Vector3.new(x,y,z)
wait(0.045)
end
end

while true do
move(0,1,0)
wait(1)
move(0,-1,0)
wait(1)
end

1 Like

You could do it like this:

local part = -- your part
local saved
local touching = false
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
saved = hit
local hrp = hit:WaitForChild("HumanoidRootPart")
touching = true
while touching == true do
wait(0.01)
hrp.CFrame = hrp.CFrame + CFrame.new(0,10,0)
end
end
end)

part.TouchEnded:Connect(function(hit2)
if hit2 == saved then
touching = false
end
end)

Everything in a localscript

I’ll test it now, I’ll notify you if it works. Thanks for taking your time to help me, by the way!

A post was merged into an existing topic: Feedback - Bypassing the 30 Character Limit

Let me check…
Edit: I didn’t really find a very good solution to this, but you can use this until you have a real one. To get off the plattform it has to be small and you have to be jumping.

local part = script.Parent
part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:IsA("Model") then
		local hrp = hit.Parent:FindFirstChild("HumanoidRootPart")
		wait(0.5)
		if hrp then
			hrp.CFrame = (part.CFrame * CFrame.new(0,(hrp.Size.Y*2.15) + 0.25,0))
		end
	end
end)

In a Normal Script though

1 Like

Thank you for taking your time to help me out, but this wasn’t realy what I was looking for and it seems buggy, I appreciate anyway. But I think I’ll stick with the seat until I find an actual solution, thank you anyway.

1 Like

Update: This topic had a useful script inside of a part that helped me learn, thanks to @EgoMoose for that!

1 Like