Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Humanoid falls through moving block?

Asked by 7 years ago

So I'm still having trouble this one. Its a timed block that acts like an elevator. Players keep falling through it though and Can Collide is checked. How do I keep them from falling through?

speed = 5000


wait(10)
local startingPos = game.Workspace.Elevator.Position
        local endingPos = game.Workspace.Elevator.Position + Vector3.new(0,30,0)
        local elevator = game.Workspace.Elevator

        for ratio = 0,speed,5 do
            local newPosition = startingPos:lerp(endingPos, ratio/speed)
            elevator.Position = newPosition
            wait()
        end

        wait(10)

        local startingPos = game.Workspace.Elevator.Position
        local endingPos = game.Workspace.Elevator.Position + Vector3.new(0,-30,0)
        local elevator = game.Workspace.Elevator

        for ratio = 0,speed,5 do
            local newPosition = startingPos:lerp(endingPos, ratio/speed)
            elevator.Position = newPosition
            wait()
        end

1 answer

Log in to vote
1
Answered by 7 years ago

Players keep falling through because of the player clipping through the elevator. I suggest you using BodyVelocity to move the elevator and BodyGyro to keep the elevator rotation. It is a much easier way and it works much better Here's an example:

local elevator = script.Parent
speed 
local bodyvel = Instance.new("BodyVelocity", elevator)
bodyvel.Velocity = Vector3.new(0, 0, 0)
local bodygyro = Instance.new("BodyGyro", elevator)
local startingpos = elevator.Position
local endingpos = elevator.Position + Vector3.new(0, -30, 0)
--Now we make the elevator go up to the ending position
while true do
    wait()
    bodyvel.Velocity = Vector3.new(0, -1, 0) -- you can change the -1 to whatever speed you want
    if elevator.Position == endingpos then
        bodyvel.Velocity = Vector3.new(0, 0, 0)
    end
end

Also, please, for the sake of god, don't use game.Workspace when working with these things

Ad

Answer this question