Moving platform wont go vertical correctly

i made this script with the help of youtube but the script is only for horizontal movement, i made the Finish part and Start part be different levels of height. this makes it do: from start it goes up, then it moves to finish, then it goes down. moves to start instead of slowly going up and moving to the next part.

local SPEED = 10;

local start = script.parent:WaitForChild("Start");
local finish = script.Parent:WaitForChild("Finish");

local attach0 = Instance.new("Attachment");
attach0.CFrame = CFrame.new();
attach0.Parent = script.Parent;

local attach1 = Instance.new("Attachment");
attach1.CFrame = finish.CFrame;
attach1.Parent = game.Workspace.Terrain;

local pris = Instance.new("PrismaticConstraint");
pris.ActuatorType = Enum.ActuatorType.Motor;
pris.MotorMaxForce = math.huge;
pris.Attachment0 = attach1;
pris.Attachment1 = attach0;
pris.Parent = script.parent;

local forward = true;
pris.Velocity = SPEED;
attach1.CFrame = finish.CFrame

start.Touched:Connect(function(hit)
	if (hit == script.Parent and not forward) then
		forward = true;
		pris.Velocity = SPEED;
		attach1.CFrame = finish.CFrame
	end
end)

finish.Touched:Connect(function(hit)
	if (hit == script.Parent and forward) then
		forward = false;
		pris.Velocity = -SPEED;
		attach1.CFrame = start.CFrame
	end
end)

1 Like

I am absolutely confused on what you’re trying to do here. It seems like you’re trying to move a part between two locations.

local Platform = workspace.Platform -- Your platform
shared.TweenService = game:GetService'TweenService'
local StartingPosition, EndingPosition = Vector3.new(0,0,0), Vector3.new(10,10,10) -- where to start and end
Platform.Position = StartingPosition
shared.TweenService:Create(Platform,
    TweenInfo.new(5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, -1, true), {
        Position = EndingPosition
    }
):Play() -- This will go back and forth every 5 seconds.

the script from original post works fine, the problem is this: https://gyazo.com/0be60d665bc4fc5fb2acf273f213de11
it doesnt smoothly go from one to another, it goes down or up first making it hard to stand on
and btw the locations are: MovingPart has 3 things in it: Finish, Start and a script
its supossed to diagonally go to the next part

Why don’t you just use TweenService? As given with the script I gave? This automatically makes the best path for it.

1 Like

its one of the first scripts i actually full on scripted and it took me awhile so i didnt wanted to delete it but ill use urs

1 Like

https://gyazo.com/f79a4d3e33126a561ce21cce06d60056 this isnt exactly the best solution

I have no words on what just happened LOL, is the part anchored? Does the part have anything else parented to it?

Nope, it’s a part and it’s only child is the script. And it’s not anchored

Maybe just add a tween thingy to my script? Maybe that will work, instead of locations to know where to go to and stuff I use a Start and Finish part where the platform goes to

i havent been able to fix it, can you maybe do a small bit of change into my script to just make it go in a straight line because ur script glitches

Works fine on my end as an anchored part. If it’s unanchored there will be issues.

Are you able to stand on it easily without sliding off fast

Probably a yes:

Just raycast beneath the character and align them ontop of it.

1 Like

this gave me a solution to not sliding off (currently having errors but i created a new topic for that) but still no solution for the moving platform itself, i used @Warriorfoox 's script which worked just now but the platform doesnt really move smoothly, 1: it goes slow and then super fast to reach the destination which causes the player to slide off even with the jailbreak script and 2: it moves in pieces (it stutters) and not smoothly.