local active_range = 500 --when platform will start moving local max_move = 400 --adjusts how far the platform moves local speed = 50 --adjusts how fast the platform moves (adjust max_move and speed together) local falling_height_mod = 100 --when to start triggering damage so player wont fall forever local kill_on_fall = 1 --set to 1 if you want the script to kill the player when he falls (i.e. no terrain below the player or to set a spike trap etc you can leave at 0 if the player will naturally die from the fall damage) local moved = {} local state = {} function moving_platform_init(e) state[e] = "wait" moved[e] = 0 end function moving_platform_main(e) if GetPlayerDistance(e) < active_range then if state[e] == "wait" then state[e] = "move forward" elseif state[e] == "move forward" then if moved[e] < max_move then CollisionOff(e) MoveForward(e,speed) CollisionOn(e) moved[e] = moved[e] + 1 else state[e] = "move back" end elseif state[e] == "move back" then if moved[e] > -max_move then CollisionOff(e) MoveForward(e,-speed) CollisionOn(e) moved[e] = moved[e] - 1 else state[e] = "move forward" end end else state[e] = "wait" end --player dis if kill_on_fall == 1 then if g_PlayerPosY < g_Entity[e]['y'] - falling_height_mod and GetPlayerFlatDistance(e) < 100 then HurtPlayer(e,g_PlayerHealth) end end end function moving_platform_exit(e) end function GetPlayerFlatDistance(e) tPlayerDX = (g_Entity[e]['x'] - g_PlayerPosX) tPlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ) return math.sqrt(math.abs(tPlayerDX*tPlayerDX)+math.abs(tPlayerDZ*tPlayerDZ)); end