Help making Elevator like JToH

Hey! I’m trying to make an elevator part like in JToH. I have scripted something, but it isn’t as good as JToH’s elevators. Any help is appreciated.

local players = not script.Parent:FindFirstChild("IgnorePlayers")
local boxes = not script.Parent:FindFirstChild("IgnoreBoxes")
local speed = script.Parent:GetAttribute("Speed")
local maxForce = script.Parent:FindFirstChild("MaxForce") and script.Parent.MaxForce.Value or math.huge
script.Parent.Touched:Connect(function(part)
	if script.Parent:FindFirstChild("Activated") and not script.Parent.Activated.Value then return end

	local torso = part.Parent:FindFirstChild("Torso") or part
	if (not torso:FindFirstChild("EVelocity") and (part.Parent:FindFirstChild("Humanoid") and players) or ((part.Name == "Pushbox" or part:FindFirstChild("IsBox") ~= nil) and boxes)) then
		local velocity = Instance.new("BodyVelocity", torso)
		velocity.Name = "EVelocity"
		local uv=script.Parent.CFrame.UpVector
		local maxf=Vector3.new(0,maxForce,0)
		if uv.X ~= 0 then maxf = Vector3.new(maxForce, maxf.Y, maxf.Z) end
		if uv.Z ~= 0 then maxf = Vector3.new(maxf.X, maxf.Y, maxForce) end

		velocity.MaxForce = maxf
		velocity.Velocity = script.Parent.CFrame.UpVector*speed
	end
end)
script.Parent.TouchEnded:Connect(function(part)
	local torso = part.Parent:FindFirstChild("Torso") or part
	if torso:FindFirstChild("EVelocity") and (part.Parent:FindFirstChild("Humanoid") and players) then torso.ElevatorVelocity:Destroy() end
end)

How do I want the elevator?
I want it to be like immeadiate and affective like JTOH. Videos will be provided when it finishes uploading.

My Elevator:

JToH Elevator

1 Like

Ok I am not good at humanoid manipulation or all the physics stuff but try checking if the players character is touching an elevator part every frame using runService and if so move the characters root part up by a bit on the yAxis or apply a force to move them up along the Y Axis, you can check if the player is touching any given part using GetPartsInPart. I’ve noticed that in the JToH video the player is launched significantly higher and if that’s intentional then that uses the roblox physics stuff which I cannot help you with.

1 Like

Alright. I looked at both the codes, and our code is almost identical, I don’t get why theirs is more affective than mine.

1 Like

Roblox physics stuff can be very finicky, even if the script logic is fine some wrong application of forces or whatever or minor discrepancies in the codecan make it work not as intended

1 Like

Yeah. The only difference is theirs is in a module script and mine is ain a servber script. Idk.

1 Like

If you have their script try applying that to your game without modifying it, only changing what you have to, to make it work for your set of parts and see if that yield any different result. Turning it from a module to a server script would be easy. Also see how the module is being invoked by whatever script they have doing so

1 Like

I really don’t want to have to like modify everything in my game, but I’ll give that a try.

1 Like

Just set enabled property of your current scripts to false it will deactivate them without having to delete anything

1 Like

Alright. I just feel like having my own systems for it and JTOH would cause lag.

1 Like

Try the JTOH one and see if it works better, if not you can resort to your own

1 Like

JToH one does work better, but I want it to be my own. But I will try JToH to see if it causes lag.

1 Like

Status Update

I got it to work, I just modified the local script.

Here’s the working code if anybody is wanting to make something like this and has a similar issue.

local rs = game:GetService("ReplicatedStorage")

local p = game.Players:GetPlayerFromCharacter(script.Parent)
script.Parent:WaitForChild("Humanoid").Touched:Connect(function(tp)
		if tp.Name == "Elevator" and not script.Parent.Torso:FindFirstChild("EVelocity") then

			local velocity = Instance.new("BodyVelocity", script.Parent:WaitForChild("Torso"))
			velocity.Name = "EVelocity"
			local uv=tp.CFrame.UpVector
			local maxf=Vector3.new(0,tp.MaxForce.Value,0)
			if uv.X ~= 0 then maxf = Vector3.new(tp.MaxForce.Value, maxf.Y, maxf.Z) end
			if uv.Z ~= 0 then maxf = Vector3.new(maxf.X, maxf.Y, tp.MaxForce.Value) end

			velocity.MaxForce = maxf
			velocity.Velocity = tp.CFrame.UpVector*tp.Speed.Value
		
			
		end 
		tp.TouchEnded:Connect(function()
		if script.Parent:WaitForChild("Torso"):FindFirstChild("EVelocity") then
			script.Parent.Torso.EVelocity:Destroy()
		end
		end)
	end)```
1 Like