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.
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.
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
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
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)```